0
我在ASP.NET MVC3中開發,我有下面的代碼保存在Sql Server 2008中的文件,它適用於IE瀏覽器(我使用IE9),但在Firefox中,我得到錯誤「索引超出範圍,必須是非負數,小於集合的大小。\ r \ n參數名稱:索引」,我該如何解決這個問題?謝謝Valums Ajax文件上傳在IE瀏覽器但不在Firefox中工作
[HttpPost]
public ActionResult FileUpload(string qqfile)
{
try
{
HttpPostedFileBase postedFile = Request.Files[0];
var stream = postedFile.InputStream;
App_MessageAttachment NewAttachment = new App_MessageAttachment
{
FileName = postedFile.FileName.ToString().Substring(postedFile.FileName.ToString().LastIndexOf('\\') + 1),
FilteContentType = postedFile.ContentType,
MessageId = 4,
FileData = new byte[postedFile.ContentLength]
};
postedFile.InputStream.Read(NewAttachment.FileData, 0, postedFile.ContentLength);
db.App_MessageAttachments.InsertOnSubmit(NewAttachment);
db.SubmitChanges();
}
catch (Exception ex)
{
return Json(new { success = false, message = ex.Message }, "application/json");
}
return Json(new { success = true }, "text/html");
}