Reputation: 623
I am trying to use upload control in angular Js. The functionality works fine in chrome, but does not work in IE 11. Below is the code used:
<div>
<input type="file" class="form-control" id="imageUploadfile" name="Imagefile" ng-files="getTheFiles($files)" accept="image/*" />
<input type="button" name="imageUploadButton" ng-click="uploadFiles()" value="Upload" />
</div>
In the controller.js file,
var formdata;
$scope.getTheFiles = function ($files) {
formdata = new FormData();
angular.forEach($files, function (value, key) {
formdata.append(key, value);
});
};
$scope.uploadFiles = function () {
TestAPIService.postUploadImage(formdata).success(function (response) {
var imageurl = _TestBaseUrl + 'Images/' + response.filePath.split(/(\\|\/)/g).pop();
$scope.testTypeImage_url = imageurl;
}).error(function (response) {
alert(response.responseText);
});
};
The above code is working fine in chrome, where I am able to upload the file. The error is in formdata , as the "key, value" are not getting added.
How to fix this? Thanks
Upvotes: 4
Views: 10308
Reputation: 8914
FormData is not fully supported by IE11 so you might need to polyfill it. Only the constructor
and the append
method are supported by IE, all other methods are unsupported.
You can find a polyfill here: https://github.com/jimmywarting/FormData
Upvotes: 2
Reputation: 323
This worked for me,
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
using 'IE=edge' it will instruct to IE to use the latest document mode available. It is recommended to have this meta tag in your webpages which specially involved with JQuery/Ajax implementations.
Upvotes: 3