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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With