上传文件时未定义FileTransfer()

时间:2017-01-16 10:13:58

标签: javascript file cordova file-upload file-transfer

我正在尝试在我的移动应用中上传文件,我已经安装了file-transefer插件,以及文件插件,但FileTransfer()提供了未定义的值

我的javascript和HTMLcode如下

 function uploadPhoto() {

var imageURI = document.getElementById('imgUpld').getAttribute("src");
if (!imageURI) {
    alert('Please select an image first.');
    return;
}

//set upload options
var options = new FileUploadOptions();
options.fileKey = "file";
options.fileName = imageURI.substr(imageURI.lastIndexOf('/') + 1);
options.mimeType = "image/jpeg";

var ft = new FileTransfer();
ft.upload(imageURI, encodeURI("http://Some-serverpath/documents/"), win, fail, options);

}

HTML代码:                    提交表格

<script type="text/javascript" charset="utf-8" src="cordova.js"></script>
<script type="text/javascript" charset="utf-8">
  <body>
     <form enctype="multipart/form-data">
      <input id="fileUpload" type="file" style="  width:100%;"
  class="filestyle" data-input="false"
  data-buttontext="Upload Doc.">
    <div id="image-holder" class="virtualPlaceholder"> </div>
    <input type="button" id="btnSubmit" value="Submit">
  </form>
 </body>    
 <script src="../scripts/jquery-1.11.3.min.js"></script>
<script src="../scripts/bootstrap.js"></script>
<script src="../scripts/bootstrap.min.js"></script>

<script src="../scripts/Fileupload.js"></script>

<script src="../scripts/FileTransfer.js"></script>
<script src="../scripts/FileTransferError.js"></script>
<script src="../scripts/FileUploadOptions.js"></script>
<script src="../scripts/FileUploadResult.js"></script>
/body>

有什么解决方案吗?在此先感谢

0 个答案:

没有答案