Forum Moderators: open

Message Too Old, No Replies

Javascript to preview local images before uploading - PLEASE HELP

javascript and local images

         

celebx

11:13 pm on Sep 1, 2006 (gmt 0)

10+ Year Member



Hi!

I am looking for a solution to enable users to preview images they upload to my site before they upload them.

In the past this could be done easily via an onchange on the file element wich would aply it's value to an image. But now in IE7 this does not seem to work.

Does anyone know a solution for this?

Best Regards,
Snt

Rambo Tribble

2:11 am on Sep 2, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Since onchange is a specified event for a file input in the DOM 2, this is probably just a beta bug. If I were you, I'd file a bug report with MS and then it will probably be fixed in the final release (hurry, rumor has it MS is about to release IE7 as final).

[edited by: Rambo_Tribble at 2:12 am (utc) on Sep. 2, 2006]

carguy84

3:16 am on Sep 3, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This is what I came up with for my uploader:
<input type="file" name="f1" accept="image/jpeg" onchange="document.preview.src=this.value;">

<img src="/images/spacer.gif" name="preview" width="300" border="0">

The width=300 is just because some files could be bigger then the upload page width. So this cuts it down.

Chip-