How to Upload Image in SharePoint 2010 Picture Library Using Visual WebPart

2 posts, 1 answers
  1. Siddiqali
    Siddiqali avatar
    13 posts
    Member since:
    May 2011

    Posted 12 Sep 2011 Link to this post

    Hi to  All,
                   This is siddiqali Working on Sharepoint 2010 Using Visual webpart.I am using Rad Controls .,I need to upload image in Sharepoint 2010 Picture Library using Visual Web-part .Can any one tell me how it is possible.


  2. Answer
    Kalina avatar
    918 posts

    Posted 27 Sep 2011 Link to this post

    Hello Siddiqali,

    You can try to upload image files in SharePoint 2010 Picture Library programmatically with RadUpload (or RadAsyncUpload) – just open the library and add the files in this way:

    <telerik:RadUpload id="RadUpload1" runat="server" ControlObjectsVisibility="None" />
    <asp:Button runat="server" ID="Button1" Text="Submit" OnClick="Button1_Click" />

    protected void Button1_Click(object sender, System.EventArgs e)
        using (var site = new SPSite("http://localhost"))
            using (SPWeb web = site.OpenWeb())
                SPPictureLibrary pics = (SPPictureLibrary)web.Lists["MyPictureLibrary"];
                foreach (UploadedFile file in RadUpload1.UploadedFiles)
                    using (Stream fs = file.InputStream)
                        pics.RootFolder.Files.Add(file.GetName(), fs);

    Please find the sample attached.

    Kind regards,
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Back to Top