我可以在Sharepoint Online的沙盒WebPart中上传文件吗?如果可以,我该如何做?
我搜索了很多,发现只有解决方案,可用于客户端对象模型的外部客户端,没有示例如何使用JSOM (Javascript的客户端对象模型)和通常的方式上传asp:FileUpload在沙盒解决方案中不起作用,PostedFile长度=0
发布于 2013-01-14 23:05:37
经过一番搜索,我终于找到了基于Codeplex的SPServices的解决方案。有一个插件SPWidgets(https://github.com/purtuga/SPWidgets/)。这个插件加载一个带有upload.asmx的iframe (Sharepoint的默认上传表单),然后为这个页面上的所有元素设置display: none,除了inputtype=file和adds按钮,它可以在iframe中提交表单。提交后,插件捕获iframe状态(_onIFramePageChange事件),并根据iframe url执行一些回调。
这看起来像一些丑陋的变通方法,但这是我在搜索几个小时后找到的唯一有效的解决方案。
发布于 2013-03-14 23:52:33
您可以选择使用ActiveX STSUpld.UploadCtl控件-这使您能够像在文档库中看到的那样提供多文件上载。
请注意,在下面的代码中,必须设置- Confirmation-URL (上传完成时的目标位置),并且还必须将目标设置为现有文档库。
<script type="text/jscript">
function DocumentUpload() {
var uploadCtl = document.getElementById("idUploadCtl");
uploadCtl.MultipleUpload();
}
</script>
<input type='hidden' name='Confirmation-URL' id='Confirmation-URL' value='' />
<input type='hidden' name='PostURL' id='PostURL' value='' />
<input type="hidden" name="Cmd" value="Save" />
<input type="hidden" name="putopts" value="true" /> <!-- Overwrite files -->
<input type="hidden" name="VTI-GROUP" value="0" />
<input type="hidden" name="destination" id="destination" value="/TestDL" /> <!-- Files destination path, must already exist -->
<p style="margin-left:auto;margin-right:auto;margin-top:0px;margin-bottom:0px;text-align:center;padding:0px !important; vertical-align:top;width:100%;">
<script type="text/javascript">
try {
if (new ActiveXObject("STSUpld.UploadCtl"))
document.write("<OBJECT id=\"idUploadCtl\" name=\"idUploadCtl\" CLASSID=\"CLSID:07B06095-5687-4d13-9E32-12B4259C9813\" WIDTH=\"600px\" HEIGHT=\"250px\" ></OBJECT>");
}
catch (error) {
}
</script>
<asp:Button runat="server" accesskey="O" id="OKButton" CssClass="ms-ButtonHeightWidth" OnPropertyChange="if (this.value != 'Upload files') this.click();" Text="Upload files" UseSubmitBehavior="False" OnClientClick="DocumentUpload(); return false;" />
<asp:Button runat="server" accesskey="C" id="CancelButton" CssClass="ms-ButtonHeightWidth" Text="Cancel" UseSubmitBehavior="False" OnClientClick="window.location ='<somewhere to go>'; return false;" />希望这能帮上忙。
发布于 2012-12-26 07:07:03
没有太多的选择,但请查看CodePlex上的SPServices -这将是最好的起点。记住- SharePoint在调用服务时需要一个二进制对象。您必须先捕获文件并将其转换为二进制文件,然后调用web服务进行上传。
我有一个例子,但不在我现在的位置-如果以上不能让你开始,让我知道,我会找到并张贴。
https://stackoverflow.com/questions/14018097
复制相似问题