Hi everyone,
I am trying to build a simple mechanism for a file upload that is then transfered to an external server. Therefore I use the cordovaFileTransfer plugin. I use a simple input field (file input) in the template to trigger the native filepicker:
<input style="display:none" type="file" id="uploadfile" data-tap-disabled="true" onchange="angular.element(this).scope().upload(this.files)" />
And then my upload function:
$scope.upload = function(files) {
var options = {
mimeType: files[0].type,
fileName: files[0].name
}
$cordovaFileTransfer.upload($rootScope.APIEndpoint +'upload/', files[0].name, options)
.then(function(result) {
console.log("SUCCESS: " + JSON.stringify(result.response));
}, function(err) {
console.log("ERROR: " + JSON.stringify(err));
}, function (progress) {
// constant progress updates
});
};
The problem here is, that the cordovaFileTransfer upload requires a full path of the file which i don’t get out of the file input field. I only have the name of the uploaded file.
Is there
- a way to get the full path of the uploaded file from an input field
or 2) a better method to let users upload a file?
THX in advance!