我尝试使用 JCOM 将文档上传到 SharePoint 文档库,但我遇到元数据问题:浏览器控制台说"类型错误:SP。FileCreationInformation 不是构造函数",并在"this.fi = new SP.文件创建信息();"
<SharePoint:ScriptLink ID="ScriptLink1" runat="server" Name="SP.js" Localizable="false" OnDemand="False" LoadAfterUI="True"></SharePoint:ScriptLink>
<SharePoint:ScriptLink ID="ScriptLink2" runat="server" Name="SP.Core.js" Localizable="false" OnDemand="False" LoadAfterUI="True"></SharePoint:ScriptLink>
<SharePoint:ScriptLink ID="ScriptLink3" runat="server" Name="SP.Runtime.js" Localizable="false" OnDemand="False" LoadAfterUI="True"></SharePoint:ScriptLink>
<SharePoint:ScriptLink ID="ScriptLink4" runat="server" Name="SP.Debug.js" Localizable="false" OnDemand="False" LoadAfterUI="True"></SharePoint:ScriptLink>
<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(
function () {
ExecuteOrDelayUntilScriptLoaded(DDLBindData, "sp.js");
}
);
var array = [];
var counter = 1;
function DDLBindData() {
var clientContext = new SP.ClientContext.get_current();
var web = clientContext.get_web();
clientContext.load(web);
clientContext.executeQueryAsync(Function.createDelegate(this, this.OnQuerySucceeded), Function.createDelegate(this, this.OnQueryFailed));
this.listCollection = web.get_lists();
this.list = this.listCollection.getByTitle("TestLib");
this.contentTypeCollection = this.list.get_contentTypes();
this.fi = new SP.FileCreationInformation();
clientContext.load(this.contentTypeCollection);
clientContext.executeQueryAsync(Function.createDelegate(this, this.OnQuerySucceeded), Function.createDelegate(this, this.OnQueryFailed));
}
但是智能向我展示了其他功能,例如文件创建信息
ECMA(JSOM) 脚本不能用于上传文件。
请参阅 http://social.technet.microsoft.com/Forums/sharepoint/en-US/34cc5d22-f47b-4ac4-9057-bbcc9f9baadd/ecma-script-for-uploading-image-to-sharepoint-2010-document-library?forum=sharepointdevelopmentprevious