I have to submit form with an image + some additional form fields (mulitipart form submission request). I have tried this
function upload() {
var img = document.getElementById('image');
var imageURI = img.value;
var options = new FileUploadOptions();
options.fileKey = "photo";
options.fileName = imageURI.substr(imageURI.lastIndexOf('/') + 1);
var params = new Object();
options.params = params;
var ft = new FileTransfer();
ft.upload(imageURI, "https://www.example.com/upload.php", win, fail,
options);
}
function win(r) {
console.log("Code = " + r.responseCode);
console.log("Response = " + r.response);
console.log("Sent = " + r.bytesSent);
}
function fail(error) {
alert("An error has occurred: Code = " + error.code);
console.log("upload error source " + error.source);
console.log("upload error target " + error.target);
}
html is
<input type="file" id="userImage" name="photo">
but it is returning error code 1 and image path is fakepat\1089001 it is also not getting picture name instead a number is showing? so how do i get image path from input text box?
If i hard code the image (only for testing) in src then request
error code 1 undefined varailbe image
Remember i have to submit image in base64 url