How to get path of selected file in AngularJS

2019-09-07 02:56发布

问题:

I'm trying to get the path of a selected file in my Ionic cordova app. Both in browser and ionic app path is empty. How can I extract this information?

{
  "0": {
    "name": "abc.jpg",
    "lastModified": 1477556723897,
    "lastModifiedDate": "2016-10-27T08:25:23.897Z",
    "webkitRelativePath": "",
    "size": 18779,
    "type": "image/jpeg",
    "slice": function slice() { [native code] }
},
"length": 1,
"item": function item() { [native code] }
}  

var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
  $scope.upload = function(){
    document.getElementById('fileu').click();
$scope.fileNameChanged = function(filoename) {
  console.log(filoename.files);
				
}}})
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="myApp" ng-controller="myCtrl">
  <input type="file" id="fileu" style="display:none" onchange="angular.element(this).scope().fileNameChanged(this)" />
  <button ng-click="upload()">Upload</button>
  </div>