/ Published in: ASP
I use this action code with http://valums.com/ajax-upload/ to handle the upload from any browser.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
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. }