Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular IE9 fileupload is not working

I use this way to upload file:

  <input type="file" 
         name="upload-file" 
         ng-model= "excelFile" 
         accept=".xlsx" 
         onchange="angular.element(this).scope().fileChanged(this);"
         required="true" 
  />

Create the fileChanged method in the controller

 $scope.fileChanged = function(files) {
     $scope.excelFile = files[0];
 };

It works in FireFox, Chrome IE10, IE11, but in IE9 it shows that the "files is null our undefined".

like image 949
Shankar Kamble Avatar asked Aug 24 '14 13:08

Shankar Kamble


3 Answers

I faced the same issue when uploading image files. It worked fine in IE10 and later versions. Any version below 10 , file upload is not working. Refer this link

IE9Issue : File Upload using AngularJS

like image 128
Janaki Sathiyamurthy Avatar answered Nov 10 '22 06:11

Janaki Sathiyamurthy


There is no way to use IE9 and below with the your method. You have two possible ways: 1. Use Flash uploader in case of IE9 and lower. Try to avoid this scenario 2. Use the http://malsup.com/jquery/form/ which will give you "some sort" of file access, as HTML 5 does :)

like image 2
Wexoni Avatar answered Nov 10 '22 07:11

Wexoni


As mentioned any method of file upload that uses FormData and File API stuff won't work in IE9 as they aren't available until IE10.

However, two angular modules that have a fallback method that will work with IE9 for uploading files that I know of are:

  • nervgh/angular-file-upload
  • danielfarid/angular-file-upload: however, it requires Flash to be installed for IE9 uploads

I am using nervgh/angular-file-upload as it does not require Flash.

like image 1
KennyE Avatar answered Nov 10 '22 07:11

KennyE