【发布时间】:2013-07-05 21:44:05
【问题描述】:
我正在尝试在异步模式下使用 Kendo UI Upload(MVC 包装器)。事情在 Chrome 中似乎运行良好,但在 IE 中没有这样的运气(目前仅在 IE 9 中测试)。当它启动上传时,我可以看到它击中了我的操作方法,并且请求包含我期望的数据,但实际上没有保存任何内容。
代码示例如下:
_EditForm.cshtml(上传位置)
@(Html.Kendo().Upload()
.Name(string.Format("upload{0}", "background"))
.Multiple(true)
.Events(evt => evt.Success("refreshBackgroundImages"))
.Messages(msg => msg.DropFilesHere("drag and drop images from your computer here")
.StatusUploaded("Files have been uploaded"))
.Async(a => a.AutoUpload(true)
.SaveField("files")
.Save("UploadImage", "Packages", new { siteId = Model.WebsiteId, type = "background" })))
控制器动作方法
[HttpPost]
public ActionResult UploadImage(IEnumerable<HttpPostedFileBase> files, Guid siteId, string type)
{
var site = _websiteService.GetWebsite(siteId);
var path = Path.Combine(_fileSystem.OutletVirtualPath, site.Outlet.AssetBaseFolder);
if (type == "background")
{
path = Path.Combine(path, _backgroundImageFolder);
}
else if (type == "image")
{
path = Path.Combine(path, _foregroundImageFolder);
}
foreach (var file in files)
{
_fileSystem.SaveFile(path, file.FileName, file.InputStream, file.ContentType, true);
}
// Return empty string to signify success
return Content("");
}
【问题讨论】:
-
@AndreiMikhalevich - 抱歉,刚刚更新了问题以包含该问题。这是第 9 版。
-
@AndreiMikhalevich 看起来就是这样,这就是为什么我更困惑为什么它可以在 Chrome 中运行,而不是在 IE 中运行。
-
也许你的 _fileSystem 对象工作不正确?
-
我正在广泛使用它,还没有看到任何其他问题。这确实很奇怪。
标签: asp.net-mvc asp.net-mvc-4 kendo-ui asyncfileupload kendo-asp.net-mvc