Mathew Vivek
2011-Sep-15 10:38 UTC
Browser compatibility Issue : Upload and Preview using Paperclip
Hi, I am using uploading(img) process in my app using paperclip. My new requirement is to preview before submitting. My new requirement works only in FIREFOX not in IE,CHROME,SAFARI. My code looks this. <%= form.file_field :image, :onchange=> "setImage(this);" %> function setImage(file) { if(document.all) document.getElementById(''prevImage'').src = file.value; else document.getElementById(''prevImage'').src file.files.item(0).getAsDataURL(); if(document.getElementById(''prevImage'').src.length > 0) document.getElementById(''prevImage'').style.display ''block''; } Thanks in Advance Mathew -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Tim Shaffer
2011-Sep-15 11:55 UTC
Re: Browser compatibility Issue : Upload and Preview using Paperclip
You basically need to preview an <input type="file"> before it has been submitted? This sounds more like a JavaScript question than a Rails question. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/1J14epSK7g8J. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Mathew Vivek
2011-Sep-15 13:58 UTC
Re: Browser compatibility Issue : Upload and Preview using Paperclip
Tim Shaffer wrote in post #1022142:> You basically need to preview an <input type="file"> before it has been > submitted? This sounds more like a JavaScript question than a Rails > question.This issue corresponds to javascript+css concept only. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Colin Law
2011-Sep-15 15:27 UTC
Re: Re: Browser compatibility Issue : Upload and Preview using Paperclip
On 15 September 2011 14:58, Mathew Vivek <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Tim Shaffer wrote in post #1022142: >> You basically need to preview an <input type="file"> before it has been >> submitted? This sounds more like a JavaScript question than a Rails >> question. > > This issue corresponds to javascript+css concept only.In that case a Ruby on Rails mailing list may not be the best place to get help. But in your situation the first thing I would try is to run it in firebug in firefox to check for errors. Also paste the complete page html into the w3c html validator to check for valid html. Differences between browsers is often caused by invalid html. Colin -- gplus.to/clanlaw -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Mathew Vivek
2011-Sep-16 06:39 UTC
Re: Re: Browser compatibility Issue : Upload and Preview using Paperclip
Colin Law wrote in post #1022182:> On 15 September 2011 14:58, Mathew Vivek <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >> Tim Shaffer wrote in post #1022142: >>> You basically need to preview an <input type="file"> before it has been >>> submitted? This sounds more like a JavaScript question than a Rails >>> question. >> >> This issue corresponds to javascript+css concept only. > > In that case a Ruby on Rails mailing list may not be the best place to > get help. > > But in your situation the first thing I would try is to run it in > firebug in firefox to check for errors. Also paste the complete page > html into the w3c html validator to check for valid html. Differences > between browsers is often caused by invalid html. > > Colin > > -- > gplus.to/clanlawThanks Colin for your idea.. I have checked my HTML that has some errors. But now i changed. It is valid now but the issue remains the same. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Colin Law
2011-Sep-16 07:46 UTC
Re: Re: Re: Browser compatibility Issue : Upload and Preview using Paperclip
On 16 September 2011 07:39, Mathew Vivek <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Colin Law wrote in post #1022182: >> On 15 September 2011 14:58, Mathew Vivek <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >>> Tim Shaffer wrote in post #1022142: >>>> You basically need to preview an <input type="file"> before it has been >>>> submitted? This sounds more like a JavaScript question than a Rails >>>> question. >>> >>> This issue corresponds to javascript+css concept only. >> >> In that case a Ruby on Rails mailing list may not be the best place to >> get help. >> >> But in your situation the first thing I would try is to run it in >> firebug in firefox to check for errors. Also paste the complete page >> html into the w3c html validator to check for valid html. Differences >> between browsers is often caused by invalid html. >> >> Colin >> >> -- >> gplus.to/clanlaw > > > > Thanks Colin for your idea.. > I have checked my HTML that has some errors. > But now i changed. It is valid now but the issue remains the same.And running it with firebug in firefox? Colin -- gplus.to/clanlaw -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Mathew Vivek
2011-Sep-16 08:30 UTC
Re: Re: Re: Browser compatibility Issue : Upload and Preview using Paperclip
Colin Law wrote in post #1022271:> On 16 September 2011 07:39, Mathew Vivek <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >>> get help.> > And running it with firebug in firefox? >I didnt see any errors in firebug. I have tried another script right now. it is working in ubuntu(firefox,chrome).. I have to check the windows os and will update it. thanks once again. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Matt Jones
2011-Sep-16 15:53 UTC
Re: Browser compatibility Issue : Upload and Preview using Paperclip
On Sep 15, 6:38 am, Mathew Vivek <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Hi, > > I am using uploading(img) process in my app using paperclip. My new > requirement is to preview before submitting. > > My new requirement works only in FIREFOX not in IE,CHROME,SAFARI. My > code looks this. > > <%= form.file_field :image, :onchange=> "setImage(this);" %> > > function setImage(file) { > if(document.all) > document.getElementById(''prevImage'').src = file.value; > else > document.getElementById(''prevImage'').src > file.files.item(0).getAsDataURL(); >To be honest, I''m surprised this works at all - file fields are notoriously resistant to being read via JS, for security reasons. If this is a critical part of your application, you may need to go to an alternative method (Flash, for instance) to have it work reliably across browsers and security settings. --Matt Jones -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.