I have a form to allow the user upload images.
The user browse for an image in their computer and click open, th
image to be upload is preview on the img tag.
The script works fine with IE, but does not work with mozilla Netscap
bowsers.
Does anyone knows what could be the problem?
Does the ONchange function works in Netscape?
Or anyone knows a tag that can preview the image file before uploadin
it.
<script language="JavaS cript" type="text/JavaScript">
function preview(thisImg ,thisObj)
{
var filename = "";
var nothing = "";
filename = "file:\/\/"+thisObj.value ;
var fileExtension
filename.substr ing(filename.la stIndexOf(".")+ 1);
if (fileExtension == "jpg" || fileExtension == "jpeg" |
fileExtension == "gif")
{ thisImg.src="fi le:\/\/"+thisObj.value ; }
else
{ alert ("Only jpg, jpeg and gif file
are allowed."); }
}
</script>
<form name="form2" method="post" enctype="multip art/form-data">
<img src="images/default.gif" name="myimga" width=100 height=8
border=0>
<INPUT NAME="upfile" TYPE="file" SIZE="80
ONchange="previ ew(myimga,upfil e);">
<INPUT NAME="upload" TYPE="submit" VALUE="Upload">
</form
-
miart
Comment