Reputation: 436
I need to get the full file name using a directive with angular js , Below is my code, here I am only getting the file name. Is it possible to get the full file name?
<input type="file" fileread="justice.imageLocation" />
MyApp.directive('fileread', [function(){
return {
scope: {
fileread:"="
},
link: function (scope, element, attributes) {
element.bind("change", function (changeEvent) {
scope.$apply(function () {
// I am getting file name here!
scope.fileread = changeEvent.target.files[0].name;
});
});
}
}
}]);
Upvotes: 0
Views: 12106
Reputation: 11
Try this:
function readURL(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
$('#tryy').attr('src', e.target.result);
}
reader.readAsDataURL(input.files[0]);
}
}
$("#tryyyy").change(function(){
readURL(this);
});
Upvotes: 0
Reputation: 13
I know this is old post but if someone is trying to do this in node webkit, just change .name to .path so it looks like this: changeEvent.target.files[0].path;
That worked for me.
Upvotes: 0
Reputation: 2740
This is actually a javascript/html question and has nothing to do with angular.
However it is simply not possible to get the path of a file client side, see this question for more information:
Upvotes: 0