Revision: 32892
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at October 4, 2010 10:56 by jink
Initial Code
byte[] uploadedbytes = null; //IE: if (Request.Files.Count > 0) { foreach (string file in Request.Files) { HttpPostedFileBase hpf = Request.Files[file] as HttpPostedFileBase; if (hpf.ContentLength == 0) continue; uploadedbytes = new byte[hpf.InputStream.Length]; hpf.InputStream.Read(uploadedbytes, 0, uploadedbytes.Length); break; } } //Chrome/FF: else if (Request.InputStream != null && Request.InputStream.Length != 0) { uploadedbytes = new byte[Request.InputStream.Length]; Request.InputStream.Read(uploadedbytes, 0, uploadedbytes.Length); } if (uploadedbytes != null && uploadedbytes.Length != 0) { //handle the upload here. }
Initial URL
Initial Description
I use this action code with http://valums.com/ajax-upload/ to handle the upload from any browser.
Initial Title
ASP.net MVC: Accept file upload from all browsers.
Initial Tags
file
Initial Language
ASP