我看到this article解释了如何使用客户端API从完全受信任的应用上传文件。
如何通过javascript实现此类功能?
例如,我有这个代码,其中我有文件的本地路径和SharePoint doc lib,我该如何完成它?
谢谢!
PS:我猜测客户端必须有一些完全受信任的组件才能实现这一目标,否则将成为一个javascript安全漏洞,但在这种情况下哪一个是针对SharePoint使用的? <script type="text/javascript">
var list;
var filePath;
function ShowUploadDialog() {
// get file path user chooses through a dialog
var fileDialog = document.getElementById("fileDialog");
fileDialog.click();
filePath = fileDialog.value;
// get list
var context = new SP.ClientContext.get_current();
var site = context.get_site();
var web = site.get_rootWeb();
this.collList = web.get_lists();
list = collList.getByTitle("My doc library");
context.load(list);
context.executeQueryAsync(Succeeded, Failed);
}
function Succeeded(sender, args) {
// I HAVE HERE THE list AND THE filePath, HOW CAN UPLOAD THE FILE TO THE LIST?
}
function Failed(sender, args) {
alert('request failed ' + args.get_message() + '\n' + args.get_stackTrace());
}
</script>