Sharepoint 2010 基于多个上载文件SP2010创建多个sharepoint列表项
我想基于从本地驱动器选择的多个文件创建sharepoint列表项。上载选定的多个文件后,列表应包含新的列表项(标题为文件名)和附件(一个附件/上载的文件)。好的,我使用并创建了用于保存附件的页面扩展了该列表上的自定义Web部件(带dynatree)Sharepoint 2010 基于多个上载文件SP2010创建多个sharepoint列表项,sharepoint-2010,Sharepoint 2010,我想基于从本地驱动器选择的多个文件创建sharepoint列表项。上载选定的多个文件后,列表应包含新的列表项(标题为文件名)和附件(一个附件/上载的文件)。好的,我使用并创建了用于保存附件的页面扩展了该列表上的自定义Web部件(带dynatree) public partial class ImportMultipleFilesAsListItems : LayoutsPageBase { protected void Page_Load(object sender, E
public partial class ImportMultipleFilesAsListItems : LayoutsPageBase
{
protected void Page_Load(object sender, EventArgs e)
{
//request form parameters comes from plupload
int parentFolderKey = int.Parse(Request.Form["key"]);
var file = Request.Files[0];
SPList list = SPContext.Current.Web.GetList(Request.Form["listUrl"]);
SPListItem folderItem = list.GetItemById(parentFolderKey);
if (folderItem != null)
{
string parentFolder = null;
if (folderItem.Folder != null)
{
parentFolder = folderItem.Folder.Url;
}
else
{
int slashIndx = folderItem.Url.LastIndexOf('/');
parentFolder = folderItem.Url.Substring(0, slashIndx);
}
SPListItem childFile = list.AddItem(parentFolder, SPFileSystemObjectType.File);
childFile["Title"] = file.FileName;
childFile["IsFolder"] = 0;
childFile["DocParentId"] = parentFolderKey;
childFile.UpdateOverwriteVersion();
byte[] data = new byte[file.ContentLength];
file.InputStream.Read(data, 0, file.ContentLength);
childFile.Attachments.AddNow(file.FileName, data);
}
}
}
$(function () {
var listInfo = new Object();
listInfo.key = null;
listInfo.listUrl = ctx.listUrlDir;
listInfo.__REQUESTDIGEST = $('#__REQUESTDIGEST').val();
$("#uploader").pluploadQueue({
// General settings
runtimes: 'browserplus,html5,html4',
url: $('#uploadMultipleFilesUrl').val(),
max_file_size: '50mb',
chunk_size: '1mb',
multipart_params: listInfo,
rename: true
});
// Client side form validation
$('form').submit(function (e) {
var uploader = $('#uploader').pluploadQueue();
// Files in queue upload them first
if (uploader.files.length > 0) {
// When all files are uploaded submit form
uploader.bind('StateChanged', function () {
if (uploader.files.length === (uploader.total.uploaded + uploader.total.failed)) {
$('form')[0].submit();
}
});
uploader.start();
} else {
alert('You must queue at least one file.');
}
return false;
});
$("#uploader").hide();
});
您考虑过使用文档库吗?这就是他们的目的。你的问题是什么?你只是想让我们给你做这一切的代码吗?到目前为止你做了什么?您在做什么时遇到困难?是的,我考虑过文档库,但使用列表insead有一些原因。Servy:我想使用一些内置表单(如果可能,可以从文档库多次上传)。到目前为止,我已经完成了列表的客户端异步树视图(使用dynatree)。现在我想创建一个逻辑来上传多个文件作为列表项?谢谢你在我回答之前把我的问题降低了。你可以用骡子。上载文档库,但不是作为附件,每个项目一个文档。此外,如果要将它们附加到项目上,则假定要根据文档填充的项目上还有其他字段,因此根据我的经验,这始终是一个自定义(一次性使用)批处理作业。你被否决了,因为你实际上没有问任何问题。写一份工作来做这件事并不难,只是很乏味。听起来你只是希望我们为你做那件乏味的工作。如果你想要别的东西,你没有问。我不期待任何人提供源代码。答案应该是:“不,没有办法使用内置sharepoint表单或逻辑从多个上载表单添加多个列表项”。