I am using Phonegap 5.3.1 and Android 22. I am trying to use the Filetransfer api of phonegap to transfer the images to the remote server.
var options = new FileUploadOptions();
options.fileKey="file";
options.fileName=imageData.substr(imageData.lastIndexOf('/')+1);
alert("The filename here is : " + imageData);
so here the imageData prints
content //com.android.providers.media.documents/document/image/image%3A53
and the further the below code
imageData.substr(imageData.lastIndexOf('/')+1);
does assign options.fileName = "image%3A53"
This is not the image name that I have on device. In my opinion this is causing an issue.
The javascript used to run the FileTransfer plugin says that the file is transferred successfully but I cannot find the file on the server(runing PHP).
The server response is as follows:
got response from server
Array
(
[file] => Array
(
[name] => image%3A53
[type] => image/jpeg
[tmp_name] => /tmp/php8qjZXN
[error] => 0
[size] => 137490
)
)
Also few posts say: Phonegap android unable to upload image using fileTransfer
You can not use imageUri that you get from camera success callback in FileTransfer upload method, you have to first resolve uri as a filename like this:
navigator.camera.getPicture(function(imageURI){
window.resolveLocalFileSystemURI(imageUri, function(fileEntry) {
fileEntry.file(function(fileObj) {
var fileName = fileObj.fullPath;
//now use the fileName in your method
//ft.upload(fileName ,serverURL + '/ajax.php?fname=appuploadspotimage'...);
});
});
});
Any help would be highly appreciated.