How to read the file path and display using angularjs ? [Resolved]

Posted by Kasani007 under AngularJS 1x on 4/3/2017 | Points: 10 | Views : 10268 | Status : [Member] | Replies : 1
How to read the file path and display using angularjs ?
For Security reasons browsers does not show file path and changing the path as c:/fakepath...

How can i get original path using AngularJS.




Responses

Posted by: Rajnilari2015 on: 4/3/2017 [Member] [Microsoft_MVP] [MVP] Platinum | Points: 50

Up
0
Down

Resolved
Try this (in Edge ...for other browsers, because of security reason, you won't get the absolute path name in which case you have to depend on the server API)

<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.3/angular.js"></script>
<title></title>
<script type='text/javascript'>

var app = angular.module('fileDemo', []);

app.directive('fdInput', ['$timeout', function ($timeout) {
return {
link: function (scope, element, attrs) {
element.on('change', function (evt) {
alert(evt.target.files[0].name);
alert($('#f1').val());
});
}
}
}]);


</script>
</head>
<body>
<div ng-app="fileDemo">
<input type="file" id="f1" fd-input />
</div>
</body>
</html>


--
Thanks & Regards,
RNA Team

Kasani007, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response