When I tried to use FileTransfer () to upload images from phonegap to an Android server on a remote server, I continued to receive error code 3 for each alternative file upload.
It worked once, but instantly, when I tried again, it would throw an error without even sending the file to the server.
The code I use to download the file was:
The key to his work was to add a header parameter .
options.headers = { Connection: "close" } options.chunkedMode = false;
Full code:
var options = new FileUploadOptions(); options.fileKey="file"; options.fileName=imageURI.substr(imageURI.lastIndexOf('/')+1); options.mimeType="image/jpeg"; options.chunkedMode = false; *options.headers = { Connection: "close" };* // setup parameters var params = {}; params.fullpath =imageURI; params.name = options.fileName; var ft = new FileTransfer(); ft.upload(imageURI, encodeURI(url+'/account/profile-pics'), win, fail, options); function win(r) { //file uploaded successfully } function fail(error) { alert("An error has occurred: Code = " + error.code); alert("upload error source " + error.source); alert("upload error target " + error.target); }
Varun nath
source share