View Full Version : display an image preview when browsing for image file

10-23-2002, 06:57 AM
hi, how do i display an image preview on a page when i browse for an image file through a file field...?? is it better to do it in asp or javascript..?

10-23-2002, 07:16 AM
<input type="file" name="f" onchange="document.images['preview'].src=this.value">
<img name="preview" src="defaultPic.jpg">

you may want to check first if the file is an image or not.

10-23-2002, 09:10 AM
hi, then how do u check whether it is an image file in the first place..

10-23-2002, 09:13 AM
check for the file extension