View Full Version : previewing local file before uploading

06-13-2003, 12:06 PM
Hi all,

Hopefully someone can help, I've searched the forum but can't see anything obvious...

I have a file upload script (which works fine) and would like to offer the user the ability to preview/check the file B4 actually uploading.
Does anyone know how to extract the local address from the file field and use it to display the document locally?

Thanks for any help/advice.

06-13-2003, 03:00 PM
I believe you can access the .value property of the input type="file" and just launch it. At least you can in IE-- this code is tested there.

<form action="#">
<input type="file" id="myfile" name="myfile" />
<button onclick="window.open(document.getElementById('myfile').value)">Preview</button>

06-13-2003, 04:37 PM
Many thanks, just what I was looking for. every varient I tried didn't work... easy when you know how.