I seem to have run into a wall trying to upload photos to a server using Phonegap application and an ASP.net page in server side. I've checked my code several times and the person who has written the aspx service has checked things on their side. I'm using the filetransfer and file plugin and an application error occured when calling upload method with code 1. I am trying first of all to upload image in the server using a simple request AJAX and it works. But when using phonegap plugins, it doesn't work. here is my code:
function getImage() {
navigator.camera.getPicture(uploadPhoto, function(message) {
alert('get picture failed');
}, {
quality: 100,
destinationType: navigator.camera.DestinationType.FILE_URI,
sourceType: navigator.camera.PictureSourceType.PHOTOLIBRARY
});
}
function uploadPhoto(imageURI) {
alert("entrer dans uploadPhoto");
var options = new FileUploadOptions();
options.fileKey = "file";
options.fileName = imageURI.substr(imageURI.lastIndexOf('/') + 1);
options.mimeType = "image/jpeg";
console.log(options.fileName);
var params = new Object();
params.value1 = "test";
params.value2 = "param";
options.params = params;
options.chunkedMode = false;
var ft = new FileTransfer();
ft.upload(imageURI, "http://192.168.100.165/ProjetCourtageServerSide/DownloadDocumentSinistre.aspx", function(result){
alert(JSON.stringify(result));
}, function(error){
alert(JSON.stringify(error));
}, options);
}