Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Upload multiple files show error code : 3

This question is same like asked here. I want to upload files from device to server, when uploading files ( totally 8 files) it shows error code : 3 for some files( first 5 files ) and rest of the files( last 3 files ) uploaded successfully.

My code is like:

for(i = 0;i < skiArray.length;i++){
    var options = new FileUploadOptions();
    options.fileKey = "file";
    options.fileName = skiArray[i];
    options.mimeType = "application/pdf";
    options.headers = {
            Connection: "close"
        }
        options.chunkedMode = false;
    var params = {};
    params.filePath = "/example/samp/files/ski/pdf/";
    options.params = params;
    uploadFiles("/example/samp/files/ski/pdf/"+skiArray[i],FILE_UPLOAD_URL,options);

}


//upload files to server
function uploadFiles(filelocation,url,options){
        var ft = new FileTransfer();
           ft.upload(filelocation, url,function onFileTransferSuccess(response){
               alert("File upload Success");  
           }, dbErrorHandler, options);

}

NOTE: all files are in same location and file size are nearly same(not more than 200 KB). Cordova version 3.3

Please help me to solve this error.

consloe error is like

05-08 13:02:54.204: E/FileTransfer(18180):

{"target":"http:\/\/192.168.1.4\/novema\/Novema_Apiupload.php","source":"\/example\/samp\/files\/ski\/pdf\/51308_1_SKI133R_pxsc8717.pdf","http_status":0,"code":3}
05-08 13:02:54.204: E/FileTransfer(18180): java.net.SocketException: sendto failed: EPIPE (Broken pipe)
05-08 13:02:54.204: E/FileTransfer(18180):  at com.squareup.okhttp.internal.http.HttpTransport$FixedLengthOutputStream.write(HttpTransport.java:228)
like image 872
Vini Avatar asked Nov 23 '25 08:11

Vini


1 Answers

Hi phonegap fileTransfer use HTTP multi-part POST request ,this error is due to the connection error. error code : 3 means CONNECTION_ERR

Errorr codes

  1. FileTransferError.FILE_NOT_FOUND_ERR
  2. FileTransferError.INVALID_URL_ERR
  3. FileTransferError.CONNECTION_ERR
  4. FileTransferError.ABORT_ERR

so to solve this u need to try those files again, first keep those fileUploadoptions [filelocation,url,options] in an array , and call Upload function for each item and onSuccess remove that items from array and try to call upLoad function again, inside upload function fetch one item from that array and process upload until array become empty.

like image 118
Arjun T Raj Avatar answered Nov 24 '25 20:11

Arjun T Raj