2

Whenever I try to upload using Blueimp jQuery File Upload on Internet Explore 6/9, ASP.NET cannot find the files in the request. I have basic code which looks like

[HttpPost]
public JsonResult Images()
{
    HttpPostedFileBase file = Request.Files[0] as HttpPostedFileBase;
}

My jQuery looks like:

$('#fileupload').fileupload({
                    //forceIframeTransport: true,
                    //contentType: 'multipart/form-data',
                    //replaceFileInput: false,
                    //contentType: 'text/plain',
                    //dataType: 'text/plain',
                    url: '@Url.Action("Images", "Upload")',
                    //autoUpload: true,
                    done: function (e, data) {
                        $('.file_result').html('');
                        $('.file_result').append(data.result.text + "<br>");
                    }
                });

The first part is when it's working and the second is when I'm using IE7-9. enter image description here

5
  • could you add the .js library you are loading? Commented Nov 6, 2013 at 16:22
  • I'm using the one provided in github.com/blueimp/jQuery-File-Upload/blob/master/js/… with jQuery v2.0.3 Commented Nov 11, 2013 at 7:11
  • I need to know all of the .js file you are loading Commented Nov 11, 2013 at 8:42
  • start a bounty and disappear! Commented Nov 13, 2013 at 9:04
  • Sorry man, I've been busy with work. This is a personal project I've been doing at home. I'll try the solution below in a few hours and report back. Commented Nov 13, 2013 at 15:48

2 Answers 2

12
+50

Usually this kind of problems are due for not including jquery.iframe-transport.js.

The plugin makes use of an Iframe Transport module for browsers like Microsoft Internet Explorer and Opera, which do not support XMLHTTPRequest file uploads in earlier versions.

Another problem I see in your code is that you are not setting the contentType and dataType in your javascript code and your response Content-type should be text/plain

There you can find 2 working implementation for reference:

http://www.webtrendset.com/2011/06/22/complete-code-example-for-using-blueimp-jquery-file-upload-control-in-asp-net/

https://github.com/i-e-b/jQueryFileUpload.Net

Sign up to request clarification or add additional context in comments.

1 Comment

Hello @giammin , I'm having the same issue, I tried to change the content-type to text/plain and when I check the request which is being sent using fiddler the filename is empty and no files are being pushed to the server. I'm using IE 11. Any Help is appreciated !!
0

I had an issue similar to this one, so hopefully the resolution will help someone out:

What I'm doing is sending the files to a web method in a WCF service, and then just writing them to a folder on the web server. Everything worked fine in Firefox and Chrome, but with IE (unfortunately we're required to support IE), the file content was being sent in the header, but not written on the server.

When I looked at the traffic with Fiddler, what ended up happening is that when the request was sent with IE, the FileName property was "C:\somelocalclientfolder\somefile.txt" in the HttpContext request. In Chrome and Firefox, it was just "somefile.txt". I added in some statements to parse and extract just the filename, and poof, problem solved. File gets successfully written in IE, Chrome, and Firefox.

Also, as others have mentioned, you need to set the response Content-Type to "text/plain" if the request is made with IE. .NET has some classes that will return the type of browser used to make the request, so I just use those to determine server-side if IE is making the request and then only set the Content-Type to "text/plain" for that specific situation.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.