[英]How can I use dropzone.js to upload files to a SharePoint file Library using SPServices?
[英]Upload File to Sharepoint List using SPservices
我在嘗試從文件選擇器上傳附件時遇到問題。 當我添加要上傳的文件時,我得到了錯誤。
無法獲取未定義或空引用的屬性“ 0”
它指向行var file = $("#SupportDoc").files[0];
這是我的代碼。 任何幫助都會很棒。
<div class="form-group" style="margin:10px;">
<label for="exampleFormControlFile1" style="border:none;">Supporting Documentation</label>
<input style="border:none;" type="file" class="form-control-file" id="SupportDoc">
</div>
-
function attach(){
var file = $("#SupportDoc").files[0];
getFileBuffer(file).then(function(buffer) {
var binary = "";
var bytes = new Uint8Array(buffer);
var i = bytes.byteLength;
while (i--) {
binary = String.fromCharCode(bytes[i]) + binary;
}
$().SPServices({
operation: "AddAttachment",
listName: "Tasks",
listItemID: taskID,
fileName: file.name,
attachment: btoa(binary)
});
});
}
用這個替換你的行
var file = document.getElementById("SupportDoc").files[0];
要么
var file = $("#SupportDoc")[0].files[0]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.