hi, i have the following code
<input type="file" ng-model-instant id="inputFile" onchange="angular.element(this).scope().setFiles(this.files)" />
.controller('ChatsCtrl', function($scope, Friends, $http, $cordovaFile) {
$scope.setFiles = function(files) {
$scope.filePath = files[0].name;
$scope.info = files[0];
$http.get(files[0].name).success(function(response){
Friends.setNewText(response);
});
/*$cordovaFile.readFile(files[0]).then(function(result) {
$scope.info = result;
}, function(err) {
$scope.info = err;
});*/
};
I have a few questions :
-
the file input seems to return just the fileName (and not the full path) both on Android and in WebView (that’s prob a security feature). How am i supposed to load it when i dont know the full path?
files[0].toString() does not have anything about containing folder or absolute location, just name, size, last modified. -
right now i get around issue #1 by placing the file to load in the www/ folder so $http loads it just fine. I also noticed that http would load it fine if i package the file inside the .apk in the same www/ folder. That’s fine for testing right now but is no go in the long term. Is there anywhere else that http would work - meaning outside the .apk ?
-
i am assuming the answer to issue #2 is NO WHERE. So i want to get my code working in both WebView and Android. I can check using :
http://ionicframework.com/docs/api/utility/ionic.Platform/
whether I am on WebView and use http
OR
Android and use cordovaFile right? Would that work?
thanks in advance!