I'm trying to upload my image in base64 to my server using cordova-plugin-file-transfer and until now it's not working. My code is like this:
photoBase64 = photoBase64.replace('data:image/png;base64,', '');
var url = "http://MYURL.com/path";
var options = new FileUploadOptions();
options.fileKey = "file";
options.fileName = "photoName.png";
options.mimeType = "image/png";
var ft = new FileTransfer();
ft.upload(photoBase64,
encodeURI(url),
function(result) {
console.log("Code = " + result.responseCode);
console.log("Response = " + result.response);
console.log("Sent = " + result.bytesSent);
resolve("OK");
},
function(error) {
alert("An error has occurred: Code = " + error.code);
console.error("ERROR", error);
console.log("upload error source " + error.source);
console.log("upload error target " + error.target);
reject("ERROR");
},
options);
And I'm getting the following error with this code:
How can I upload image base64 using cordova-plugin-file-transfer?
Thanks in advance!