我正在为 MVC3 C# 使用 Uploadify v3.1。
我的cshtml代码是
<div class="container_24">
<input type="file" name="file_upload" id="file_upload" />
</div>
我的js代码是
$(document).ready(function () {
$('#file_upload').uploadify({
'method': 'post',
'swf': '../../Scripts/uploadify-v3.1/uploadify.swf',
'uploader': 'DashBoard/UploadFile'
});
});
控制器代码是
[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");
}
现在,当我单击上传按钮时,它会显示两个错误,有时会显示 IO 错误,有时会显示某些文件的HTTP 404错误。怎么了 ?请帮帮我 ?