Sharepoint多个Ajax调用-需要一个示例,以通过REST API将附件上传到列表项 [英] Sharepoint Multiple Ajax calls - Need an example for Uploading attachments to list item thru REST API

查看:48
本文介绍了Sharepoint多个Ajax调用-需要一个示例,以通过REST API将附件上传到列表项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

请任何人帮我完成以下任务.

Could you please any of you help me on getting the below task done.

我正在尝试将附件上传到同一列表中的各个项目.当我尝试使用客户端脚本+ rest api方法时,便能够添加附件.

I am trying to upload the attachments to various items on the same list. As i am trying client side scripting + rest api method am able to add the attachment. 

但是我有多个文件要上传,需要一个示例来实现.  

But i have multiple files to upload and need an example to achieve this.  

代码:

加纳

Dhana-Chennai-India

Dhana-Chennai-India

推荐答案

I根据您的代码做了一些更新,您可以检查代码以供参考.

(在页面上添加内容编辑器Web部件,并在其中添加以下代码)

(function(){
(function () {


(#uploadDocumentButton").click(功能 () { if(document.getElementById("inputFile").files.length === 0){ alert(选择文件!"); 返回; } var parts = document.getElementById("inputFile").value.split("\\"); var filename = parts [parts.length-1]; var file = document.getElementById("inputFile").files [0]; uploadFile("ListA","1",文件名,文件); } ) }) 函数uploadFile(listName,listId,fileName,file){ uploadFileSP(listName,listId,fileName,file) .然后( 功能(文件){ alert(成功上传"); }, 功能(发送方,参数){ alert(args.get_message()); } ); } 函数getFileBuffer(file){ var deferred =
("#uploadDocumentButton").click(function () { if (document.getElementById("inputFile").files.length === 0) { alert("Select a file!"); return; } var parts = document.getElementById("inputFile").value.split("\\"); var filename = parts[parts.length - 1]; var file = document.getElementById("inputFile").files[0]; uploadFile("ListA", "1", filename, file); } ) }) function uploadFile(listName, listId, fileName, file) { uploadFileSP(listName, listId, fileName, file) .then( function (files) { alert("Uploaded successfully"); }, function (sender, args) { alert(args.get_message()); } ); } function getFileBuffer(file) { var deferred =


这篇关于Sharepoint多个Ajax调用-需要一个示例,以通过REST API将附件上传到列表项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆