когда я пробовал приложение, все работает отлично. Журнал успеха появляется. Но когда я проверяю свой сервер, фотографий нет.
это мой код.
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);