我试图发送一个图片与phonegap wp8但我得到一个错误 [英] I'm trying to send a picture with phonegap on wp8 but I'm getting an error
问题描述
我尝试使用javascript和php将我的应用程序中拍摄的图片发送到我的远程服务器,但到目前为止我仍然被卡住:
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:
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");
}
PHP服务器正在运行:
The PHP server is running:
$new_image_name = "YEAH.jpg";
move_uploaded_file($_FILES["file"]["tmp_name"],"/httpdocs/app/upload/images/".$new_image_name);
这是我得到的错误:
日志:错误回调中出错:FileTransfer1933815797 = ReferenceError:
分配
Log:"Error in error callback: FileTransfer1933815797 = ReferenceError: Invalid left-hand side in assignment"
我真的希望任何人有任何经验,因为这是一个学校项目,到期在2个星期。
I really hope anyone has any experience with this, as this is for a school project which is due in 2 weeks.
推荐答案
我发现的问题是我正在呼叫一个chache位置,由于这个事实,我不能发送ajax的图像。
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.
我解决这个问题的方式是根本不发送图像,我使用base64编码将其粘贴到画布上
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
这篇关于我试图发送一个图片与phonegap wp8但我得到一个错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!