1

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

1

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

0

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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