How to get path of selected file in AngularJS

穿精又带淫゛_ 提交于 2020-01-07 03:13:25

问题


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>

来源:https://stackoverflow.com/questions/42021110/how-to-get-path-of-selected-file-in-angularjs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!