On Sep 15, 6:38 am, Mathew Vivek <[email protected]> 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 [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

