Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am using HTML5 Drag&Drop File Upload with c# asp.net . In all browsers everything work fine, but in IE10 I can't get the files in the server in order to save them. I've tried everything and nothing works. please help.

here is my code:

javascript & HTML:

C#
function uploadFile(index) {
    var files = window.opener.files; //get the files from drag area which is in window.opener
    for (var i = index; i < (index + files.length); i++) {
       debugger;
       var size = fixSize(files.item(i - index).size);
       var name = files.item(i - index).name;
       xhr.push(new XMLHttpRequest()); //create new xhr and push it to xhr array
       //var form = window.opener.document.getElementById('ddform');
       //var data = new FormData(form);
       var data = new FormData();
       data.append("index", i);
       data.append("fileName", name);
       data.append("file", files.item(i - index));
       xhr[i].open('POST', "HandlerUploadFiles.ashx", true);
       xhr[i].send(data);
    }
}


c#, using IHttpHandler:

C#
public class HandlerUploadFiles : IHttpHandler, IRequiresSessionState
{
    public void ProcessRequest(HttpContext context)
    {
       // context.Response.ContentType = "text/plain";
       string fileName = context.Request["fileName"];
       string postedFile = context.Request["file"]; // returns string : {"object file"}
       HttpFileCollection fileCollection = context.Request.Files; // always empty!!!
       ...
    }
}


The problem in IE:
The server side code hits at ProcessRequest function.
The error I get while debugging: the collection : context.request.Files is empty (count=0) .
However, the other strings values (like fullName) from XHR can be retrieved .
I thought maybe I don't send the file correctly, but in searches I did - this was the way to send it.
Like I mention before- in FF and Chrome the program works excellent

Thanks for any help.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900