7

我想在異步模式下使用Kendo UI上傳(MVC包裝)。事情似乎在Chrome中運行良好,但在IE中沒有這樣的運氣(截至目前只在IE 9中測試過)。當它啓動上傳時,我可以看到它觸及我的操作方法,並且請求包含我期望的數據,但實際上沒有保存任何內容。劍道UI異步上傳不工作在Internet Explorer中

代碼示例均低於:

_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" }))) 

控制器ActionMethod

[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(""); 
} 
+0

的IE版本? – Andrei

+0

@AndreiMikhalevich - 對不起,只是更新了這個問題。這是版本9. –

+0

@AndreiMikhalevich這就是它似乎是,這就是爲什麼我更困惑,爲什麼它在Chrome中,但不是IE。 –

回答

8

以及另外發帖稱,「歡迎來到‘爲什麼InternetExplorer不吸得很厲害’插曲52245315:

原來,當你在Internet Explorer上HttpPostedFileBasefile.FileName ,它認爲你想要的本地計算機上的文件的完整路徑。這顯然只是一個IE瀏覽器的東西如Chrome和Firefox似乎是正確的。

確保做的時候,你只需要個以下Ë實際FileName

var filename = Path.GetFileName(file.FileName); 
4

問題是,當你真正嘗試保存文件並從服務器發回成功響應。我不認爲你的演示正在做這些。 ie9中的iframe沒有收到來自服務器的響應。瀏覽器認爲響應是一個下載,儘管它只是一個純文本json響應。我將其調試到事實上iframe上的加載事件永遠不會被觸發,因此需要處理此響應的onload處理程序不會執行任何操作。在所有其他瀏覽器中,這是工作。

來源:http://www.kendoui.com/forums/kendo-ui-web/upload/async-uploader-and-ie-9-not-working.aspx

+0

我看到那篇文章,但它並沒有真正回答我的問題。服務器似乎是**返回它應該是什麼,但它實際上並不保存文件。 –

相關問題