Is there a way to access a file from a type="file"
input in javascript?
The purpose is to send it with XHR afterwards.
Example :
<input type="file" id="myFile"/>
var file = $('#myFile');
With AngularJS :
<input type="file" file-changed/>
.directive('fileChanged', function(){
return {
link : function(scope, element){
element.on('change', function(e){
if(e.target.value != ""){
scope.myCtrl.file = e.target;
}
});
}
}
)
.controller('myCtrl', function(){
var self = this;
self.file;
//self.file should be available here for XHR.
});
Global need :
Multiple input type files needs to be send to a REST api.
I need to keep track of the progress of each file upload, WITHOUT using an external libary.