上传前在本地判断文件大小
<script language="Jscript">
function chksize(strFileName){
var maxsize = 100; //定义允许文件的大小,单位KB,请根据需要自行修改!
var objStream = new ActiveXObject("ADODB.Stream");
objStream.Type = 1;
objStream.Open();
objStream.LoadFromFile(strFileName);
if(Math.round(objStream.Size/1024,2)>maxsize)
{alert ("抱歉!您选择的文件为 "+Math.round(objStream.Size/1024,2)+" KB n超过了程序"+maxsize+" KB 的限制!");
document.form1.reset();
return false;
}
}
</script>
<form name="form1" action="" method="post">
<input type="file" name="Upfile" >
</form>