var url =ApiEndpoint.url+'upload.php'; //
// File for Upload
var targetPath = $scope.pathForImage($scope.image);
// File name only
var filename = $scope.image;
var options = {
fileKey: "file", //file
fileName: filename,
chunkedMode: false,
mimeType: "multipart/form-data",
params : {'fileName': filename}
}
$cordovaFileTransfer.upload(url, targetPath, options).then(function(response) {
$scope.sendPicMessage();
$ionicLoading.hide();
}, function(err) {
$ionicLoading.hide();
alert("ERROR: " + JSON.stringify(err));
}, function (progress) {
// alert(progress);
// constant progress updates
//console.log(progress)
});
}
i think you should use it like this:
var ft = new FileTransfer();
ft.upload(targetPath, encodeURI(url), win, fail, options);
function win(result) {
console.log("SUCCESS: " + JSON.stringify(result.response));
$ionicLoading.hide();
}
function fail(error) {
console.log("ERROR: " + JSON.stringify(error));
$ionicLoading.hide();
}
same issue it cannot get the $scope.image when it comes to ios, but for android it’s working perfectly