如何在文档库中获取上传文件文档的项目ID。 [英] How can i get Item ID of uploaded file document in Document Library.

查看:102
本文介绍了如何在文档库中获取上传文件文档的项目ID。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello Experts, 

Hello Experts, 

我有一个文档库,库有一个文件夹,我上传文件到该文件夹使用以下代码。

I have one document library, library has one folder and I upload file to that folder using below code.

我的文件已成功上传。但我希望得到父项目ID,其中包含文件夹。 

My file uploaded successfully. but i want to get parent item id where folder is present. 

示例:

图书馆姓名:XYZ

文件夹名称:D1

所以,我想要获得D1上传后的文件夹项目ID 此文件夹中的文件用于进一步处理。

文件上传代码。

推荐答案

您好sachsoni,

Hi sachsoni,

您可以使用下面的Rest API获取特定文件夹项ID:

You could get the specific folder item id with Rest API like below:

<script type="text/javascript" src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script type="text/javascript">
var folderrelativeurl="/XYZ/D1";


.ajax({
url:_spPageContextInfo.siteAbsoluteUrl +" / _ api / web / getfolderbyserverrelativeurl(' " + folderrelativeurl +"')/ listitemallfields / id",
type:" GET",
contentType:" application / json; odata = verbose",
headers:{
"接受":"application / json; odata = verbose",
"X-RequestDigest":
.ajax({ url: _spPageContextInfo.siteAbsoluteUrl + "/_api/web/getfolderbyserverrelativeurl('"+folderrelativeurl+"')/listitemallfields/id", type: "GET", contentType: "application/json;odata=verbose", headers: { "Accept": "application/json;odata=verbose", "X-RequestDigest":


(" #__ REQUESTDIGEST")。 val()
},
成功:函数(数据){
console.log(data.d.Id);

},
错误:function(data){
alert(JSON.stringify(data));
}
});

< / script>
("#__REQUESTDIGEST").val() }, success: function (data) { console.log(data.d.Id); }, error: function (data) { alert(JSON.stringify(data)); } }); </script>

谢谢

最佳报告


这篇关于如何在文档库中获取上传文件文档的项目ID。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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