0

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.

4

1 回答 1

0

我发现的问题是我正在调用一个 chache 位置,因为我无法使用 ajax 发送图像。

我解决这个问题的方法是根本不发送图像,我使用 base64 编码将其粘贴到画布中,然后我能够从图像中获取平均颜色,之后我能够将值发送到我的服务器.

我将很快添加我的代码片段

于 2013-06-05T21:02:01.940 回答