因为ie9 不支持 js 验证大小,所以改用ajax 后台做验证 ,不过发现验证了之后,fileupload 的路径消失了 ...不知道哪里出了错 ?
前台 js :
function ajaxFileUpload() {
$.ajaxFileUpload({
url: 'ajax.ashx',
secureuri: false,
fileElementId: 'FileUpload1',
dataType: 'json',
success: function(data, status) {
if (typeof (data.error) != 'undefined') {
if (data.error != '') {
alert(data.error);
}
}
},
error: function(data, status, e) {
alert(e);
}
})
}
string error = "";
string msg="";
HttpPostedFile file = context.Request.Files[0];
int iFileSize = file.ContentLength;
if (iFileSize > 100000)
//检查images size
{
error = "size limit 100jb";
string result = "{ error:'" + error + "'}";
context.Response.Write(result);
}
else
{
string result = "{ error:'" + error + "'}";
context.Response.Write(result);
}