I need to upload image file into the sharepoint 2010 picture library using java script...
requirement is --
we have File Upload control
And, we have to upload image file from that file upload control
Please can you see my code...But this code doesnt work.
If anybody has a better solution that would be nice.
Thanks in advance.
<script>
function updateListItem()
{
var clientContext = new SP.ClientContext.get_current();
var oList = clientContext.get_web().get_lists().getByTitle('Test');
var itemCreateInfo = new SP.ListItemCreationInformation();
this.oListItem = oList.addItem(itemCreateInfo);
oListItem.set_item('Title', My Image);
oListItem.update();
clientContext.load(oListItem);
clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
}
function onQuerySucceeded()
{
alert('Item updated!');
}
function onQueryFailed(sender, args)
{
alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}
</script>
<input id="FileUpload" type="File" /><br />
<br />
<input onclick="updateListItem()" id="UploadImage" type="submit" value="Upload" />