Transfer file to server - not working

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 = "";
// 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) {

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?

Your file location url seems wrong.

I advise not to hardcode file url, instead try to get the relative path to your app, then access files in folders accordingly.

For example

let filePath = this.file.dataDirectory + "fileFolder/" + "myFile.mp4"