我正在关注使用Phonegap将图像上传到服务器的this教程。数据将发送到服务器但无法上载。这是我尝试将图片上传到服务器时的响应。
这是我的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);
}
这是服务器的结构
答案 0 :(得分:0)