Jquery File Upload – Not sending headers in IE9

I’m using jQuery Fileupload to upload files. Its not sending headers that I set to the server. Why is the Authorization header missing only in IE but passed in chrome?

Here is the code:

upload_photo: function(){
  var url =  '/api/v1/upload';
  $('#photoupload').fileupload({
      url: url,
      dataType: 'json',
      paramName: 'uploadFile',
      beforeSend: function ( xhr ) {
          setHeader(xhr);
          $("#check_progress").html('true');
      },                    
      done: function (e, responseJSON) {
          var id = responseJSON.result.id;
          url = responseJSON.result.url;
          var photo_ids = $("#photo_ids");
          var val = photo_ids.val();
          photo_ids.val(val + id.toString() + ",");
          $(".photothumb-wapper").append('<div class=/"photothumb/" id="post_photo_'+id+'"><div><img  src=/"'+url+'/" /></div><img class=/"thumb-delete photo_delete/" id=/"'+id+'/" title=/"Remove/" src=/"/assets/delete-red.png/"></div>');
          $("#check_progress").html("");
      },
      start: function (e, data) {
          $(".photothumb-wapper").append('<div class="photothumb photoprogress" style="border:none"><img src="/assets/ajax-loader.gif" /></div>');
      },
      always: function (e, data) {
          $(".photoprogress").remove();
      }
  });
}

var setHeader = function (xhr) {
    xhr.setRequestHeader('Authorization', 'Bearer fdf49c4f1cfgc176eb952f18eeefaec3e7');
};

Headers passed in IE:

Request             : POST /api/v1/upload HTTP/1.1 
Accept              : text/html, application/xhtml+xml, /*//* 
Referer             : url
Accept-Language     : en-US
User-Agent          :Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0) 
Content-Type        :multipart/form-data; boundary=---------------------------7de2dfe037204f6 
Accept-Encoding     :gzip, deflate 
Host                :url 
Content-Length      :776595 
DNT                 :1 
Connection          :Keep-Alive 
Cache-Control       :no-cache       
Cookie              :sitecookies

Headers passed in Chrome:

ResponseHeaders
  date : Tue, 04 Mar 2014 07:32:20 GMT
  Connection: Keep-Alive
  content-length:225
  content-type:application/json; charset=utf-8
  cache-control:no-cache
RequestHeaders
  Accept: application/json, text/javascript, /*//*; q=0.01
  Authorization: Bearer fdf49c4f1cfgc176eb952f18eeefaec3e7
  X-Requested-With: XMLHttpRequest

Why is the Authorization header missing in IE?

jquery File Upload (blueimp) – IE9 doesn’t support multiple file selection?

I’m using jquery file upload plugin per blueimp and IE9 is not allowing multiple file selection per the following code (below) or the demo: http://blueimp.github.com/jQuery-File-Upload/ Can somebody p

File upload with blueimp jQuery file upload, doesn’t work in IE9

have create an upload functionality with jQuery-file-upload, my upload work in Firefox, Chrome and IE version more than 9. I have try to force iframe transport, recommended by doc of jQuery-fileupload

jquery form file upload on IE9

I have encountered problem while uploading files on Internet Explorer 9 using Jquery Form. Basically on IE9 the code always goes to onSuccess hook even if we get error. Short background: I want to b

blueimp jquery file upload issues on ie9

having issues with the blueimp jquery file uploader, uploads fine, but no progress is reported back to the calling page, only in ie8/ie9. done seems to work properly, its only the progress part

Sending files /file upload using ajax which works in IE9

I need to upload files using ajax which has to be supported in IE9. I was using FormData as mentioned here. My code looks like this: var files = new FormData(); JQuery.each($(‘#file’)[0].files, functi

jQuery-File-Upload not firing done callback in Internet Explorer (IE9)

i checked some questions regarding the same issue, blueimp jquery file upload – done, complete callbacks not working for IE 9 , but even after putting my Content-Type as ‘text/html’ as the respons

jQuery File Upload doesn’t work in IE9 when compressed with Requirejs

My code uses Backbone with Requirejs and jQuery File Upload and works perfectly in IE 9 when I access the development code directly (without building). As soon as I build it something goes wrong and t

Angularjs, File Upload and IE9

Having file upload problems in an Angularjs/Nodejs app. I implemented this angular-file-upload directive. Using it, file upload works in all modern browsers but it fails in IE9. By fails I mean tha

File Upload progress on IE9

I’ve read in a few places that file upload progress is not supported in IE9. However I notice that gmail has some sort of solution for it. I’ve read articles from a couple of years ago that it is a fl

jQuery File Upload doesn’t send a file in IE9

I have got such problem only in IE < 10. My sources: $(input:file#upload-photo).fileupload({ enctype: multipart/form-data, url: $(input:file#upload-photo).attr(url), autoUpload: true, send:

Answers

This answers my question,

Only browsers with support for XHR file upload support setting custom headers.

As a workaround in old browsers like our dear IE, you could set a cookie with the authentication token when the user authenticate and then get it in the server and verify it the same way you verify the header one. I know that it is not the most elegant solution but it works.