Hi,
i am going through this sample example link.
Upload a File to a Remote Server with PhoneGap
http://zacvineyard.com/blog/2011/03/upload-a-file-to-a-remote-server-with-phonegapBut when i hit to local server this throws file upload error code 3
This is my code :-
<!DOCTYPE HTML>
<html>
<head>
<title>File Transfer Example</title>
<script type="text/javascript" charset="utf-8" src="cordova.js"></script>
<script type="text/javascript" charset="utf-8">
// Wait for PhoneGap to load
document.addEventListener("deviceready", onDeviceReady, false);
// PhoneGap is ready
function onDeviceReady() {
// Do cool things here...
}
function getImage() {
// Retrieve image file location from specified source
navigator.camera.getPicture(uploadPhoto, function(message) {
alert('get picture failed');
},{
quality: 50,
destinationType: navigator.camera.DestinationType.FILE_URI,
sourceType: navigator.camera.PictureSourceType.PHOTOLIBRARY
}
);
}
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://yourdomain.com/upload.php", win, fail, options)
// when i use this URL file is NOT uploading show error code 3
ft.upload(imageURI, "http://10.0.0.2/mobile/upload.php", win, fail, options);
// when i use this URL file is uploading successfully But i am not getting file in that location
ft.upload(imageURI, "http://192.9.200.164:8080/bdmbs/uploads/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);
}
</script>
</head>
<body>
<button onclick="getImage();">Upload a Photo</button>
</body>
</html>
upload.php file code <?php
print_r($_FILES);
$new_image_name = "namethisimage.jpg";
move_uploaded_file($_FILES["file"]["tmp_name"], "/srv/www/upload/".$new_image_name);
?>
how to set system path "/srv/www/upload/" my path C:\upload/
and request is hitting to server
http://192.9.200.164:8080/bdmbs/uploads/upload.php and the message show file sent success.
i need to set the location where images are save ?