Jquery file uplaod fail showing
Hi I am using jquery file upload showing fail i have tried with diffeerent
datatype but still showing fail, i can show my image uploaded but done
event is not firing, fail event is firing.
$('#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;
}
});
Controller
======================================
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;
}
}
Please any one help me on it asap.
No comments:
Post a Comment