gpt4 book ai didi

php - 文件上传成功,但服务器中没有照片(phonegap android)

转载 作者:行者123 更新时间:2023-11-30 03:34:53 25 4
gpt4 key购买 nike

当我试用该应用程序时,一切正常。出现成功日志。但是当我检查我的服务器时,没有照片。

这是我的代码。

script.js

$('#gallery_page').live('pageshow', function(){
getGallery();
$('#library').bind('click', function(){
photo_library();
getGallery();
});
});

function photo_library(source) {
var pictureSource; // picture source
var destinationType; // sets the format of returned value

document.addEventListener("deviceready",onDeviceReady,false);

function onDeviceReady() {
pictureSource=navigator.camera.PictureSourceType;
destinationType=navigator.camera.DestinationType;
};

navigator.camera.getPicture( uploadPhoto, onFail, { quality: 50,
destinationType: destinationType.FILE_URI,
sourceType: pictureSource.PHOTOLIBRARY });
};

function uploadPhoto(imageURI) {
var options = new FileUploadOptions();
options.fileKey="file";
options.fileName=imageURI.substr(imageURI.lastIndexOf('/')+1);
options.mimeType="image/jpeg";
options.chunkedMode = false;
var ft = new FileTransfer();
ft.upload(imageURI, "http://*my_ip*/TA/php/upload.php", win, fail, options, true);
};

upload.php

include 'db.php';
print_r($_FILES);
$new_image_name = "namethisimage.jpg";
move_uploaded_file($_FILES["file"]["tmp_name"], "http://*my_ip*/TA/php/".$new_image_name);

最佳答案

这一行应该改一下

move_uploaded_file($_FILES["file"]["tmp_name"], "http://*my_ip*/TA/php/".$new_image_name);

move_uploaded_file($_FILES["file"]["tmp_name"], "/PATH/ON/SERVER/TA/php/".$new_image_name);

代码应该是这样的:

upload.php

include 'db.php';
print_r($_FILES);
$new_image_name = "namethisimage.jpg";
move_uploaded_file($_FILES["file"]["tmp_name"], "/var/www/php/".$new_image_name);

关于php - 文件上传成功,但服务器中没有照片(phonegap android),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16755626/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com