Error while uploading image (cordova-plugin-file-transfer)

1

I am using the same documentation code. , but when I send to PHP, there is no file.

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);

The http code returns 200 OK in the success function but $ _FILES appears empty ...

    
asked by anonymous 03.10.2017 / 22:24

1 answer

0

After trying several solutions and nothing works, I decided to remove the cordova plugins and add again, I do not know exactly why, but it finally worked!

cordova plugin remove cordova-plugin-file
cordova plugin remove cordova-plugin-file-transfer

cordova plugin add cordova-plugin-file
cordova plugin add cordova-plugin-file-transfer
    
13.10.2017 / 19:40