uploadify错误HTTP:undefined?

可能重复:
Uploadify:显示来自HTTP响应的错误消息

我想在我的asp.net mvc 3应用程序中使用Uploadify。 我收到一个错误(见标题)。 这是我的看法:

@{ ViewBag.Title = "Home Page"; }     Upload File  $(document).ready(function () { $("#fileInput1").uploadify({ uploader: '@Url.Content("~/Scripts/uploadify.swf")', script: '@Url.Action("Upload", "Upload")', fileDataName: 'file', buttonText: 'File Input 1...', multi: false, sizeLimit: 22222222222, simUploadLimit: 1, cancelImg: '@Url.Content("~/Scripts/cancel.png")', auto: false, onError: function (a, b, c, d) { if (d.status == 404) alert("Could not find upload script. Use a path relative to: " + ""); else if (d.type === "HTTP") { console.log("error " + d.type + ": " + d.status); alert("error " + d.type + ": " + d.status); } else if (d.type === "File Size") $("#result").html("file too big"); //alert(c.name + " " + d.type + " Limit: " + Math.round(d.info / (1024 * 1024)) + "MB"); else alert("error " + d.type + ": " + d.text); }, onComplete: function (event, queueId, fileObj, response, data) { alert(response); } }); });  

您最常得到的错误可能表示应该处理文件上载的服务器端操作存在一些问题。 我怀疑会抛出一些exception。

尝试使用以下控制器:

 public class HomeController : Controller { public ActionResult Index() { return View(); } [HttpPost] public ActionResult Upload(HttpPostedFileBase file) { if (file != null && file.ContentLength > 0) { var appData = Server.MapPath("~/app_data"); var filename = Path.Combine(appData, Path.GetFileName(file.FileName)); file.SaveAs(filename); } return Json(true); } } 

还可以尝试使用更新版本的jquery和uploadify。 我刚刚使用jquery 1.5.1进行了测试,并使用您发布的完全相同的代码和我显示的控制器操作上传了2.1.4,并且它工作得很好。

这是我的Index.cshtml视图:

      Upload File