如何在AngularJS中获取所选文件的路径

时间:2017-02-03 09:38:26

标签: javascript angularjs cordova ionic-framework

我试图在我的Ionic cordova应用程序中获取所选文件的路径。 浏览器和离子应用程序路径都是空的。我该如何提取这些信息?

{
  "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>
&#13;
&#13;
&#13;

0 个答案:

没有答案