<form enctype="multipart/form-data" method="post" name="upform" target="upload_target" action="upload.php">
<input type="file" name="Filedata" id="Filedata"/>
<input style="margin-right:20px;" type="submit" name="" value="上传形象照" onclick="return checkFile();" /><span style="visibility:hidden;" id="loading_gif"><img src="loading.gif" align="absmiddle" />上传中,请稍侯......</span>
</form>
上面国html页面
function checkFile()
{
var path = document.getElementById('Filedata').value;
var ext = getExt(path);
var re = new RegExp("(^|\s|,)" + ext + "($|\s|,)", "ig");
if(extensions != '' && (re.exec(extensions) == null || ext == '')) {
alert('对不起,只能上传jpg, gif, png类型的图片');
return false;
}
showLoading();
return true;
}