问题
I'm trying to send a picture, taken in my application, to my remote server using javascript and php, but so far I'm stuck:
This is the code from my application
function onPhotoDataSuccess(imageData) {
    alert(imageData);// returns:"/CapturedImagesCache/WP_20130605_021.jpg"
    //send picture to server
    var options = new FileUploadOptions();
    options.fileKey="file";
    options.fileName=imageData.substr(imageData.lastIndexOf('/')+1);
    options.mimeType="image/jpeg";
    var params = new Object();
    params.value1 = "test";
    params.value2 = "param";
    options.params = params;
    var ft = new FileTransfer();
    ft.upload(imageData, "http://***.**/app/upload/upload.php", win, fail, options);
    alert ("picture will be send");
}
The PHP server is running:
$new_image_name = "YEAH.jpg";
move_uploaded_file($_FILES["file"]["tmp_name"],"/httpdocs/app/upload/images/".$new_image_name);
And this is the error I'm getting:
Log:"Error in error callback: FileTransfer1933815797 = ReferenceError: Invalid left-hand side in assignment"
I really hope anyone has any experience with this, as this is for a school project which is due in 2 weeks.
回答1:
The problem wich i found was that i was calling to a chache location, due to that fact i was not able to send the image with ajax.
The way i solved this was to not send the image at all, i used the base64 encoding to paste it into a canvas in wich i was able to get the average color from the image after that i was able to send the values to my server.
i will add my code snippets soon
来源:https://stackoverflow.com/questions/16938368/im-trying-to-send-a-picture-with-phonegap-on-wp8-but-im-getting-an-error