如何将powerpoint文件上传到服务器phonegap?

时间:2014-06-09 04:25:02

标签: ios cordova file-upload

您好我想使用phonegap文件传输协议将powerpoint文件上传到我的本地java服务器通过ios模拟器,当用户选择使用我的应用程序打开powerpoint时,手机上文件的位置会传递给handleOpenURL函数。问题是虽然我确定这个方法正在执行,但什么也没发生?!!有人可以帮忙吗?

function handleOpenURL(url)
        {

            setTimeout(function() {
                      alert(url);

                jQuery.get( "http://192.168.1.100:8080/PpServer/getnumberofslides" ,  function( data ) {
                    numberofslides=data;
                    alert( "Load was performed." + data );
                });
                       fileURL = url;
                       function win(r) {
                       console.log("Code = " + r.responseCode);
                       console.log("Response = " + r.response);
                       console.log("Sent = " + r.bytesSent);

                     //  processapplication();
                       }

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

                       var uri = encodeURI("http://192.168.1.100:8080/NewServerlet");

                       var options = new FileUploadOptions();
                       options.fileKey="file";
                       options.fileName=fileURL.substr(fileURL.lastIndexOf('/')+1);
                       options.mimeType="multipart/form-data";
                       options.httpMethod="Post"
                     // options.params = {"file"};
                       var headers={'headerParam':'file'};

                     //  options.headers = headers;

                     var ft = new FileTransfer();
                       ft.onprogress = function(progressEvent) {
                       if (progressEvent.lengthComputable) {
                       loadingStatus.setPercentage(progressEvent.loaded /                                  progressEvent.total);
                       } else {
                       loadingStatus.increment();
                       }
                       };
                       ft.upload(fileURL, uri, win, fail, options);
                       }, 0);
          //  
        }

0 个答案:

没有答案