我需要使用Java腳本的圖像文件上傳到SharePoint 2010的圖片庫上傳圖像文件到SharePoint 2010的圖片庫......如何使用ECMA腳本
的要求是 -
1.我們有文件上傳控制
2.And,我們必須從該文件上傳控件
請參閱代碼上傳圖像文件......但是,這代碼不工作(顯示「文件」「未定義的對象」異常或'FileInfo')
如果任何機構有更好的解決方案,將是很好的。
在此先感謝。
<script>
var clientContext = new SP.ClientContext.get_current();
var oList = clientContext.get_web().get_lists().getByTitle('Test');
//var fStream = (new FileInfo(uploadimagepath)).OpenRead();
var fStream = File.OpenRead(uploadimagepath);
//var fStream = FileUpload.PostedFile.InputStream;
//var contents = new byte[fStream.Length];
var newPic = oList.RootFolder.Files.Add(phototitle, fStream);
var oItem = newPic.Item;
oItem.set_item('Title', phototitle);
oItem.update();
oList.Rootfolder.Update();
clientContext.load(oItem);
</script>
Link是關於C#,但我有在SharePoint 2010中使用Java腳本(ECMAScript)。我也在我的代碼中使用了文件上傳控件(請參閱註釋行......),但文件上傳控件也有相同的異常。 –