Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

i have list called SharesList has image column, so i need to make the end user upload image from his/her local pc... please i need any solutions immediately.



        var siteUrl = '/deanships/6thgraduation';
        var uploadedURL, itemTitle;
        function updateListItem(itemTitle,uploadedURL) {
            var clientContext = new SP.ClientContext(siteUrl);
            var oList = clientContext.get_web().get_lists().getByTitle('SharesList');
            var itemCreateInfo = new SP.ListItemCreationInformation();
            this.oListItem = oList.addItem(itemCreateInfo);
            oListItem.set_item('Title', itemTitle);
            oListItem.set_item('test', uploadedURL);

            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());
        } 
    

share|improve this question
add comment

2 Answers

Try this jQuery Add-in : http://www.phpletter.com/Our-Projects/AjaxFileUpload/

We recently worked on a similar solution. In our case we already had a REST WCF service so it was easier to add a new API with 1 single 'Stream' parameter and then use the above add-in, which basically creates an iframe with multipart form and then posts the data to a WCF Service. The service receives the data in stream and it needs to be decoded as stated here : http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/7a387bc1-fb7a-4c7b-a17f-19fc167f9621.

Hope this helps, Jomit

share|improve this answer
add comment

Have you tried this instead? http://msdn.microsoft.com/en-us/library/websvcimaging.imaging.upload.aspx

I haven't really seen ECMAScript examples uploading files in SharePoint. Either use a Silverlight Control or one of the Web Services to handle content. Client Object Model comes in many shapes (Managed, ECMA and Silverlight - each with its own constraints and limitations).

Hope it helps, C:\Marius

share|improve this answer
    
Thanks for your answer i will check it but i think it's helpful, but can i add item from picture library to list by javascript or JQuery ? –  user1115156 May 14 '12 at 20:22
    
If you would manage to wrap it around the call for the Web Service, yes you can. See here for an example blueimp.github.com/jQuery-File-Upload –  C. Marius - MVP May 14 '12 at 23:50
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.