嗨,我正在使用 jquery 文件上传显示失败我已经尝试过使用不同的数据类型但仍然显示失败,我可以显示我的图像上传但完成事件没有触发,失败事件正在触发。
$('#frmsettings').fileupload({
type: 'POST',
dataType: 'application/json',
url: '/Settings/UploadUiLogo',
add: function (e, data)
{
data.submit();
},
progressall: function (e, data)
{
},
done: function (e, data)
{
$.each(data.files, function (index, file)
{
alert("Done called");
});
},
fail: function (e, data)
{
alert("Fail : Called");
//window.location = JsErrorAction;
}
});
控制器
=======================================
public ContentResult UploadUiLogo()
{
try
{
if (Request.Files != null)
{
foreach (string file in Request.Files)
{
HttpPostedFileBase hpf = Request.Files[file] as HttpPostedFileBase;
if (hpf.ContentLength == 0)
continue;
string savedFileName = Path.Combine(Server.MapPath("~/Content/uploadlogo"), Path.GetFileName(Guid.NewGuid() + hpf.FileName));
hpf.SaveAs(savedFileName);
return Content("{\"name\":\"" + savedFileName + "\"", "application/json");
}
}
return null;
}
catch (Exception ex)
{
throw ex;
}
}
请任何人尽快帮助我。