2014-04-12 55 views
1

我正面臨上傳文件在ios phonegap大的問題,但同樣是工作的android.When我上傳文件從iphone,它給了我200即成功和發送的字節。但服務器響應是目標缺失,這意味着該文件沒有在服務器上接收,請儘可能提供給我任何解決方案。因爲無法實現項目的死線。 Thanks.I'm將在這裏分享我的代碼。上傳文件不在iphone iphone phonegap但在Android中工作正常

function upload_demo() { 
     // Retrieve image file location from specified source 
     navigator.camera.getPicture(
            uploadPhoto1, 
            function(message) { alert('get picture failed'); }, 
            { 
            quality   : 50, 
            destinationType : navigator.camera.DestinationType.FILE_URI, 
            sourceType  : navigator.camera.PictureSourceType.PHOTOLIBRARY 
            } 
            ); 
    } 

    function uploadPhoto1(imageURI) { 
     alert(imageURI); 
     alert(activefolder); 
     var url="https://server.com/****"; 
     alert(url); 
     var options = new FileUploadOptions(); 
     options.fileKey="file"; 
     options.fileName=imageURI.substr(imageURI.lastIndexOf('/')+1); 
     options.mimeType="image/jpeg"; 
     var headers = { 
        "Authorization" : auth 
       }; 
       options.headers = headers; 
       var params = {}; 
       params.target = activefolder; 
       options.params = params; 
     options.httpMethod="POST"; 
     alert(JSON.stringify(options)); 

     var ft = new FileTransfer(); 
     ft.upload(imageURI, encodeURI(url), win1, fail1, options,true); 
    } 

    function win1(r) { 
     alert("Code = " + r.responseCode); 
     alert("Response = " + r.response); 
     alert("Sent = " + r.bytesSent); 
    } 

    function fail1(error) { 
     alert("An error has occurred: Code = " + error.code); 
     console.log("upload error source " + error.source); 
     console.log("upload error target " + error.target); 
    } 

回答

0

請檢查下面的鏈接,如果有幫助: -

http://www.zacvineyard.com/blog/2011/03/upload-a-file-to-a-remote-server-with-phonegap 

options.chunkedMode = false; 

,而不是這一點,並檢查包含的所有權限

+0

任何一個有關於這個問題的任何想法你的plist ??? #phonegap #cordova –

相關問題