上传多个文件显示错误code:3 [英] Upload multiple files show error code : 3

查看:1347
本文介绍了上传多个文件显示错误code:3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此问题是同样喜欢问<一个href=\"http://stackoverflow.com/questions/19275268/phonegap-file-transfer-of-picture-fails-on-every-other-picture-error-$c$c-3-wit\">here.我想从设备上传文件到服务器,上传文件时(共8个文件),它显示错误code:3 对于某些文件(前5个文件)和文件的剩余部分(过去3个文件)上传成功。

我的code是这样的:

 为(i = 0; I&LT; skiArray.length;我++){
    VAR的选择=新FileUploadOptions();
    options.fileKey =文件;
    options.fileName = skiArray [I]
    options.mimeType =应用程序/ PDF
    options.headers = {
            连接:关闭
        }
        options.chunkedMode = FALSE;
    变种PARAMS = {};
    params.filePath =/例子/ SAMP /文件/滑雪/ PDF /;
    options.params =参数;
    uploadFiles(/例子/ SAMP /文件/滑雪/ PDF /+ skiArray [I],FILE_UPLOAD_URL,期权);}
//文件上传到服务器
功能uploadFiles(filelocation,网址,期权){
        VAR英尺=新的文件传输();
           ft.upload(filelocation,网址,功能onFileTransferSuccess(响应){
               警报(文件上传成功);
           },dbErrorHandler,期权);}

注意:所有文件都在同一个位置和文件大小几乎相同(不超过200 KB)。科尔多瓦3.3版

请帮我解决这个错误。

consloe错误是像

13 05-08:02:54.204:E /文件传输(18180):

<$p$p><$c$c>{\"target\":\"http:\\/\\/192.168.1.4\\/novema\\/Novema_Apiupload.php\",\"source\":\"\\/example\\/samp\\/files\\/ski\\/pdf\\/51308_1_SKI133R_pxsc8717.pdf\",\"http_status\":0,\"$c$c\":3}
05-08 13:02:54.204:E /文件传输(18180):java.net.SocketException异常:SENDTO失败:EPIPE(断管道)
05-08 13:02:54.204:E /文件传输(18180):在com.squareup.okhttp.internal.http.HttpTransport$FixedLengthOutputStream.write(HttpTransport.java:228)


解决方案

喜PhoneGap的文件传输使用HTTP多部分POST请求,这个错误是由于连接错误。错误code:3用于 CONNECTION_ERR

Errorr codeS


  1. FileTransferError.FILE_NOT_FOUND_ERR

  2. FileTransferError.INVALID_URL_ERR

  3. FileTransferError.CONNECTION_ERR

  4. FileTransferError.ABORT_ERR

所以要解决这个u需要再次尝试这些文件,
首先让那些fileUploadoptions [filelocation,网址选项]数组,并调用上传功能,为每个项目和的onSuccess删除从数组项,并尝试再次调用上传功能,上传的功能里面获取从阵列和过程上载一个项目,直至阵列成为空谈。

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)

解决方案

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.

这篇关于上传多个文件显示错误code:3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆