$(document).ready(function () {
$('#AvgFile').uploadify({
'uploader': '@Url.Content("~/Scripts/uploadify.swf")',
'script': '@Url.Action("uploadify", "pccommon")' + "?t=" + Math.random(),
'cancelImg': '@Url.Content("~/Scripts/cancel.png")',
'buttonImg': '@Url.Content("~/Scripts/uploadbtn.gif")',
'fileExt': '*.jpg;*.png;*.jpeg',
'fileDesc': '请选择jpg png jpeg文件',
'auto': true,
'removeCompleted': false,
'onComplete': function (event, ID, fileObj, response, data) {
deletefile("#Avg");
if (response != "" && response != "\"\"") {
if (fileObj.type == '.jpg' || fileObj.type == '.png' || fileObj.type == '.jpeg') {
$("#Avg").val(response);
$("#Avg").valid();
alert("上传完毕!");
$("#AvgErr").hide();
}
else {
$("#Avg").val(response);
deletefile("#Avg");
$('#AvgFile').uploadifyCancel(ID);
alert(fileObj.name + "-文件格式不符合要求");
return false;
}
} else {
alert("上传失败!");
}
},
'onCancel': function (event, ID, fileObj, data) {
deletefile("#Avg");
$("#Avg").val("");
},
'sizeLimit': 2097152
});
});
function deletefile(id) {
var filename = $(id).val();
var url = '@Url.Action("deletefile", "pccommon")';
$.get(url, { filename: filename });
}
function uploadfile(id) {
$(id).uploadifyUpload();
}
C#uploadify只上传图
最新推荐文章于 2019-01-03 14:49:00 发布