Reputation: 11
when i tried the application, everything works perfectly. success log is appear.but when i check in my server, there are no photos.
this is my code.
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);
Upvotes: 1
Views: 694
Reputation: 327
This line should be changed
move_uploaded_file($_FILES["file"]["tmp_name"], "http://*my_ip*/TA/php/".$new_image_name);
to
move_uploaded_file($_FILES["file"]["tmp_name"], "/PATH/ON/SERVER/TA/php/".$new_image_name);
The code should look something like this:
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);
Upvotes: 1