ng-file-upload
ng-file-upload copied to clipboard
Img Tag defalutly loading
Issue:
while uploading the image defaultly loading img tag
and where ever we are trying to upload multiple times image not clearing
Step1
Step2:
Step3
Here is HTML Code :
<div class="col-sm-3">
<input type="file" ng-click="clear()"
onchange="angular.element(this).scope().upload(event)" accept="image/png, image/jpeg,image/jpg" style="display: block;" />
</div>
<div class="col-sm-3">
<button class="btn btn-primary btn-md" ng-click="click()">Upload</button>
</div>
Here is java script code :
$scope.setImage = function (image) {
$scope.display = $scope.images[image];
}
$scope.upload = function (obj) {
var elem = obj.target || obj.srcElement;
$scope.file = elem.files[0];
var reader = new FileReader();
$scope.fileName = $scope.file.name;
reader.onload = function (e) {
$scope.display = e.target.result;
$scope.$apply();
}
reader.readAsDataURL($scope.file);
}
$scope.afterClick = false;
$scope.loadingImages = true;
$scope.errors = true;
$scope.click = function() {
$scope.loadingImages = false;
Upload.upload(
{
method : 'POST',
url : 'http://localhost:8080/image/getDeepLearningPredections',
file : $scope.file,
data : {
fileName : $scope.fileName,
}
})
.then(
function(response) {
try {
if (response.data["Status"] != "Okay") {
$scope.errors = false;
$scope.errorMessasge = response.data["Status"];
Notification
.error(response.data["Status"]);
$scope.loadingImages = true;
} else {
$scope.loadingImages = true;
var outputData = JSON
.stringify(response.data);
$scope.attributes = JSON
.parse(outputData).Attributes;
$scope.displayImage = $scope.display;
$scope.afterClick = true;
$scope.loadingImages = true;
// }
}
} catch (e) {
console.log(e);// you
}
})
}
Please Replay the issue