1
I’m using the same code as documentation, but when sending to PHP, no file appears.
JS
function uploadPhotoRevendedor(imageURI) {
var success = function (r) {
app.alert("Code = " + r.responseCode + "Response = " + r.response + "Sent = " + r.bytesSent);
}
var fail = function (error) {
app.alert("An error has occurred: Code = " + error.code + "Source = " + error.source + "Target = " + error.target);
}
var options = new FileUploadOptions();
options.fileKey = "file";
options.fileName = imageURI.substr(imageURI.lastIndexOf('/')+1);
options.mimeType = "image/jpeg";
// Upload image
var ft = new FileTransfer();
ft.upload(imageURI, encodeURI(...'model/foto-revendedor.php'), success, fail, options);
}
PHP
print_r(json_encode($_FILES));
$new_image_name = urldecode($_FILES["file"]["name"]).".jpg";
$result = move_uploaded_file($_FILES["file"]["tmp_name"], "../users/".$new_image_name);
http code returns 200 OK in Success function but $_FILES appears empty...
Is making a mistake?
– Rafael Augusto
Then returns as 200 - OK the 'responseCode', but don’t know pq in php $_FILES gets empty...
– Gabplay
Already gave a
console.log(imageURI)
? to see if you’re right?– Rafael Augusto
Yes the same as the request photo in Request URL
– Gabplay