由于项目的需要!您需要一个脚本来判断客户端的大小和文件类型!It is hard to find information on the Internet.It writes an example of a test file upload size limit, compatible with IE6, IE7, IE8, Google Chrome, FF and other browsers
复制代码代码如下所示:




无功议= / / i.test MSIE(导航。用户代理)!Window.opera;
功能filechange(目标,ID){
var文件大小= 0;
var n文件类型。JPG
var文件路径= target.value;
无功filemaxsize = 1024×2; / / 2M
如果(文件路径){
VaR紧邻=假;
无功fileend = filepath.substring(filepath.indexof(,)));
如果(文件类型文件类型。长> 0){
对于(var i = 0;i < filetypes.length;i++){
如果(文件类型{我} = = fileend){
就在=真;
打破;
}
}
}
如果(!Isnext){
警告()不接受此文件类型!;
target.value = ;
返回false;
}
其他{ }
返回false;
}
如果(议!目标文件){
var文件路径= target.value;
VAR系统=新的ActiveX对象(脚本。FileSystemObject );
如果(!filesystem.fileexists(路径)){
警报(附件不存在,请重新输入它!;
返回false;
}
var文件= filesystem.getfile(路径);
文件大小=文件大小;
{人}
文件大小=目标文件大小。{ 0 };
}

无功大小=文件大小/ 1024;
如果(大小> filemaxsize){
警报(大小的附件不能大于+ filemaxsize / 1024 +M!;
target.value = ;
返回false;
}
如果(大小< = 0){
警报(附件大小不能0m!;
target.value = ;
返回false;
}
}