i'm using Valums Ajax uploader. all works great in Mozilla with this code:
View:
var button = $('#fileUpload')[0];
var uploader = new qq.FileUploader({
element: button,
allowedExtensions: ['jpg', 'jpeg', 'png', 'gif'],
sizeLimit: 2147483647, // max size
action: '/Admin/Home/Upload',
multiple: false
});
Controller:
public ActionResult Upload(string qqfile)
{
var stream = Request.InputStream;
var buffer = new byte[stream.Length];
stream.Read(buffer, 0, buffer.Length);
var path = Server.MapPath("~/App_Data");
var file = Path.Combine(path, qqfile);
File.WriteAllBytes(file, buffer);
// TODO: Return whatever the upload control expects as response
}
which was answered in this post:
However issue is that this doesn't work in IE. I did find this but i can't figure out how to implement it:
IE doesn't send the stream in "request.InputStream" ... instead get the input stream through the HttpPostedFileBase from the Request.Files[] collection
Also, this here that shows how this guy did it but i'm not sure how to change for my project:
Valum file upload - Works in Chrome but not IE, Image img = Image.FromStream(Request.InputStream)
//This works with IE HttpPostedFileBase httpPostedFileBase = Request.Files[0]
as HttpPostedFileBase;
can't figure this one out. please help! thanks
Shane's solution works but it seems like the Request["qqfile"] is being set anyway in IE. Not sure if this is because I'm using an updated version of the fileuploader but I've modified the "if" statement to make it work for IE (checking if there are any uploaded files in the request).
Here is the full snippet
I figured it out. This works in IE and mozilla.