I am using Uploadify v3.1 for MVC3 C#.
My cshtml code is
<div class="container_24">
<input type="file" name="file_upload" id="file_upload" />
</div>
My js code is
$(document).ready(function () {
$('#file_upload').uploadify({
'method': 'post',
'swf': '../../Scripts/uploadify-v3.1/uploadify.swf',
'uploader': 'DashBoard/UploadFile'
});
});
And the controller code is
[HttpPost]
public ActionResult UploadFile(HttpPostedFileBase file)
{
// Verify that the user selected a file
if (file != null && file.ContentLength > 0)
{
// extract only the fielname
var fileName = Path.GetFileName(file.FileName);
// store the file inside ~/App_Data/uploads folder
var path = Path.Combine(Server.MapPath("~/Uploads"), fileName);
file.SaveAs(path);
}
// redirect back to the index action to show the form once again
return RedirectToAction("Index", "Home");
}
Now when i click the upload button it show two errors, sometime it show IO error and sometime it show HTTP 404 error for some file. what is wrong ? help me please ?
'swf': '@(Url.Content("~/Scripts/uploadify-v3.1/uploadify.swf"))', 'uploader': '@(Url.Action("DashBoard", "UploadFile"))'. You can additionally setup an onUploadError to find out more about the cause of the error.