IE7: Img control NOT allowed to view local files???

Hi,

I have an image preview function (in javascript) that allows the user to view an image before it is uploaded to the web site.

I use the standard upload control (type="file") which- when set by browsing to an image- is used to determine the image path on the user's local machine. For some reason IE7 refuses to display the image. This works in IE6. I have to admit that this did not work in FireFox so maybe there is some standards incompatibility that is involved.

code is :

var path=up.value; // 'up'is the upload control

img.src=path; // 'img' is the image control

I've tried various ways to modify the local path with file:/// and file://localhost/ but nothing seems to work. Any one know

Thanks!

Jack



Answer this question

IE7: Img control NOT allowed to view local files???

  • Quilnux

    I have the same problem ...

    does anyone knows why they did it.. of if this could be fixed


  • JacksonJones

    My only thought on this is that this is some sort of security issue but I can't get my head around it since, yes it is a file on the user's computer but only the user can see it!

    This is frustrating on one hand but on the other hand FireFox also does not allow loading an img tag with a local file either. My workaround Since the image in my web app was to be uploaded anyway I removed the image preview and allowed the uploaded image- now on the server- to be reviewed (for rotation and cropping). The only downside was that the user couldn't see the pre-posted image in my app, but then they could always used the File Browser to look at the image when they were selecting it.


  • Philly10407

    Thanks for this very simple solution to what has taken me hours to try and resolve. Vary helpfull indeed....



  • Bigmo

    Hi peoples, I'm in the similar boat with an image previewing feature in a CMS. The problem is security related but if possible you should get any users to add the domain to their Trusted Sites list as this will solve it without having to change any code. Hope this helps you guys. Cheers.
  • IE7: Img control NOT allowed to view local files???