I’m trying to transfer a file from my device to the server but the file is not be sending to the server. On my server UploadHandler, the HttpContext.Request
presents 0 files.
My code:
// Destination URL
var fileFullPath = "file:///applicationDirectory/fileFolder/myFile.mp4";
//File for Upload
var targetPath = "http://exampledomain.net/myWebservice/UploadHandler.ashx";
// File name only
var filename = targetPath.split("/").pop();
var options = {
fileKey: "file",
fileName: filename,
mimeType: "video/mp4",
params : {'directory':'upload', 'fileName':filename}
};
$cordovaFileTransfer.upload(fileFullPath, targetPath, options).then(function (result) {
console.log("SUCCESS: " + JSON.stringify(result.response));
}, function (err) {
console.log("ERROR: " + JSON.stringify(err));
}, function (progress) {
// PROGRESS HANDLING GOES HERE
});
What I’m doing wrong? I already tried to send by post()
method with FormData
but the file is not ever found. But the file path is right… I must write the file path in a different way? Is something missing? The file is not found because I’m testing with the device connected to my computer?