TypeError:无法在onedrive js中读取未定义的属性“焦点”

时间:2016-10-06 08:40:04

标签: javascript html onedrive filepicker

所以我一直试图通过将文件数据转换为

来将文件保存到onedrive

datauri和上传而不是使用sourceInputElementID

所以我使用文件阅读器将上传的文件转换为dataURL格式,然后将其作为源uri传递

代码:

<html>
  <head>

    <script type="text/javascript" src="https://js.live.net/v7.0/OneDrive.js"></script>

      <script type="text/javascript">

        var openfile= function(event){

             var input= event.target;
             var reader=new FileReader();

              var launchSaveToOneDrive= function (dataURL){
                       console.log("2");
                      var odOptions = {
                          clientId: "1fd8b6bd-4585-4491-a802-7bc9f0fde5da",
                          action: "save",
                       // sourceInputElementId: "",
                          sourceUri: dataURL,
                          fileName: "fil.txt",
                          openInNewWindow: true,
                          advanced: {},
                          success: function(files) { console.log('success');},
                          progress: function(p) { console.log("2"); },
                          cancel: function() {console.log("3"); },
                          error: function(e) { console.log(e); }
                        }
                        console.log("3");
                      OneDrive.save(odOptions);
                    };


              reader.onload= function() {
                launchSaveToOneDrive(reader.result);
                console.log("1");
              }
              reader.readAsDataURL(input.files[0]);
        }
</script>
</head>
<body>
    <input id="fileUploadControl" name="fileUploadControl" type="file" onchange="openfile(event)" />

</body>
</html>

但我在控制台中收到此错误

error

文本中的

错误 -

OneDrive.js:2 Uncaught TypeError: Cannot read property 'focus' of undefined
e.openPopup @ OneDrive.js:2
e.launchSaver @ OneDrive.js:3
e.save @ OneDrive.js:2
e.save @ OneDrive.js:2
launchSaveToOneDrive @ (index):29
reader.onload @ (index):34

代码托管在https://bandrevu-akhil.github.io/上,因此您可以在那里进行测试。

我的问题是他们无论如何将文件转换为datauri格式并使用sourceuri上传到onedrive?

0 个答案:

没有答案