I need to upload image file into the sharepoint 2010 picture library using java script...
requirement is --
1.we have File Upload control
2.And, we have to upload image file from that file upload control
Please see code...But this code is not working (showing "Undefined object" exception for 'File' or 'FileInfo')
If any body have better solution that would be nice.
Thanks in advance.
<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>