我正在按照本教程使用 Phonegap 将图像上传到服务器。数据被发送到服务器但无法上传。这是我尝试将图片上传到服务器时得到的响应。
这是我的php代码
<?php
header("access-control-allow-origin: *");
print_r($_FILES);
$new_image_name = "image.jpg";
move_uploaded_file($_FILES["file"]["tmp_name"], "/products/".$new_image_name);
?>
这是我在我的应用程序上运行整个事情的功能
function uploadPhoto(imageURI) {
var options = new FileUploadOptions();
options.fileKey="file";
options.fileName=imageURI.substr(imageURI.lastIndexOf('/')+1);
options.mimeType="image/jpeg";
var params = new Object();
params.value1 = "test";
params.value2 = "param";
options.params = params;
options.chunkedMode = false;
var ft = new FileTransfer();
ft.upload(imageURI, "http://clubbedin.clanteam.com/upload.php", win, fail, options);
}
function win(r) {
console.log("Code = " + r.responseCode);
console.log("Response = " + r.response);
console.log("Sent = " + r.bytesSent);
alert(r.response);
}
function fail(error) {
alert("An error has occurred: Code = " = error.code);
}
这是服务器的结构