I'm trying to implement a FileUpload function with PhoneGap. Used almost the code of the API example:
navigator.camera.getPicture(function(file) {
l(file);
var options = new FileUploadOptions();
options.fileKey ="files";
options.fileName = file.substr(file.lastIndexOf('/')+1);
options.mimeType = "image/jpeg";
var ft = new FileTransfer();
ft.upload(file, path, function(o) {
l('upload ok')
}, function(error) {
l('upload failed')
l('code: '+error.code);
l('source: '+error.source);
l('target: '+error.target);
l('http_status: '+error.http_status);
}, options, true);
}, {
quality: 75,
destinationType: Camera.DestinationType.FILE_URI,
sourceType: Camera.PictureSourceType.SAVEDPHOTOALBUM
});
The media library is opened, I chose a file, the file path is showed and then the upload fails. The error object and all output is NULL so I cannot find out why. The post request is never executed on the server. Any ideas?
I'm using current PhoneGap with build service. I added this to config.xml:
<gap:plugin name="org.apache.cordova.file" />
<gap:plugin name="org.apache.cordova.file-transfer" />
By the way, it works on iOS.
Thanks for any help