I’m using the demo page provided with the jQuery File Upload version 5.6 from Blueimp. I can get the demo working in my ASP.NET MVC project to the point where a file can be uploaded from the page.
However, even though the file successfully gets uploaded, the UI reports an error. I’m 100% certain this error is because I’m not returning the proper information from my controller action.
Here is my existing action:
[HttpPost]
public virtual JsonResult ImageUpload(FormCollection formdata)
{
var imagePath = Setting.Load(SettingKey.BlogImagesBasePath).Value;
for(var i = 0; i < Request.Files.Count; i++)
{
var saveFileName = string.Format("{0}\\{1}", imagePath, Request.Files[i].FileName);
Log.DebugFormat("Attempting to save file: {0}", saveFileName);
Request.Files[i].SaveAs(saveFileName);
}
return Json(new {});
}
I don’t know what the content of the result should be. I tried sorting through the php example but, not being at all familiar with php, the best I could make of it is that the filename, size, and type might be involved.
Does somebody have a link to a working MVC sample or provide the information I need to return the correct data to the plugin?
Sailing Judo
I think this question addresses your needs 100%:
jQuery File Upload plugin asks me to download the file, what is wrong?
here’s basically what it demos:
the class:
the action:
so, basically, you’d just need to return the jsonresult of the ViewDataUploadFilesResult collection.
Hope it helps.