0

iam trying to show image preview before upload, for that i am using code given below..

it works with firefox, but, dosent work with IE8

<%= image_tag @image, :id=>"preview-photo" %>
<%= file_field 'image','photo', :onchange => "preview(this);" %>


function preview(this) {
document.getElementById("preview-photo").src =this.value;
return;
}

i need help.. Is there any solution to preview the image in IE8 and other browsers?

S L
  • 14,262
  • 17
  • 77
  • 116
lamrin
  • 1,431
  • 4
  • 22
  • 34
  • 1
    This is no longer possible across browsers for security reasons (they serve `C:\Fakepath` instead of the real value when querying a file upload field). I do not think there is a workaround. – Pekka Apr 08 '11 at 11:00
  • any other approach to do this functionality...using any plugins??? – lamrin Apr 08 '11 at 11:05
  • Flash based uploaders can theoretically still do this, although I don't know any specific product that does it out of the box. – Pekka Apr 08 '11 at 11:08

1 Answers1

2

The only way I know of is using a flash movie for your upload. For a nice example see here.

nfechner
  • 17,295
  • 7
  • 45
  • 64