views:

75

answers:

1

I want to be able to preview an image for a user before they upload it.

I've of course discovered that all the modern browsers obscure the actual full path in one way or another, so my original plan of just setting an <img /> element with the local path is out of the question.

I've found this solution, which isn't bad, but I'm expecting the images to be a little bit large, and my users' internet connections to perhaps be a little slow, so this isn't exactly ideal.

I've found that FireFox has the getAsDataURL() method, which would work perfectly if there was some form of it in the other browsers, or at least even IE, but I haven't been able to find it.

Is there any other way to do this and have it work in IE7/8 (6 is a bonus but I don't care that much), FF2/3, and webkit without resorting to a plugin?

+1  A: 

The answers to the question you have linked tell the truth: There is no way to read files from the user's file system using JavaScript. You will need to upload the image before you can append it to your page as an <img>.

Jørn Schou-Rode
Except in HTML5.
SLaks
@SLaks: The last line of the question explicitly asks for a solution that works in Internet Explorer 7 and 8. I guess that rules HTML 5 out :(
Jørn Schou-Rode
I realize that.
SLaks
well, crap :\ was hoping there was something I wasn't finding.
Daniel Schaffer