I don't do angularjs daily, and I've tried to add a upload file button. It should only take .zip and 20 MB max. I did
Try#1
<input class="pull-right" type="file" id="fileUpload" name="fileUpload" ngf-select="$ctrl.uploadFile()" ngf-pattern="'application/zip'" ngf-max-size="20MB">
Try#2
Add
onchange="angular.element(this).scope().setFiles(this)"
<input class="pull-right" type="file" id="fileUpload" name="fileUpload" ngf-select="$ctrl.uploadFile()" ngf-pattern="'application/zip'" onchange="angular.element(this).scope().setFiles(this)" ngf-max-size="20MB">
and my component file I have
this.uploadFile = {};
this.uploadFile.Iserror=false;
this.uploadFile = function(files) {
this.uploadFile.Iserror=false;
console.log(files); //undefined
if(files[0].type!=="zip"){
alert("Not a zip file.");
this.uploadFile.Iserror=true;
return false;
}
};
What do I need to do to access the file I selected ?