More in this section

Forums / Developing with Sitefinity / Image gallery on file system

Image gallery on file system

2 posts, 0 answered
  1. Yan St-Yves
    Yan St-Yves avatar
    8 posts
    Registered:
    18 Jan 2007
    03 Mar 2009
    Link to this post
    Hi,

    I'm creating a simple image gallery using the Image module in the admin pages.

    Is it possible to save the images on disk instead of in the database?

    I currently have DB size restriction and putting many images in the DB is not really great.

    Thanks in advance,

    Yan
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    03 Mar 2009
    Link to this post
    Hello Yan St-Yves,

    I regret to inform you that images uploaded through Images and Documents module cannot be stored outside of the database. One way is to create Custom control using RadUpload and specify the path where your items will be uploaded. Another way is to upload the image manually to some system folder and use it as a source later.

    <telerik:RadUpload ID="RadUpload1" InitialFileInputsCount="10" runat="server" ControlObjectsVisibility="AddButton" Width="400" EnableEmbeddedSkins="false" Skin="Sitefinity" OverwriteExistingFiles="true" /> 
     

    You can access the current RadUploadContext object using the RadUploadContext.Current property:

    RadUploadContext uploadContext = RadUploadContext.Current;  

    The RadUploadContext object provides the UploadedFiles collection, which contains all uploaded files in the current request. Using the UniqueID property of the FileUpload control you can get and save its file:

    UploadedFile file = uploadContext.UploadedFiles(FileUpload1.UniqueID); 
    if (!file == null
     file.SaveAs(Server.MapPath("~/MyFiles/" + file.GetName())); 

    You can just use an foreach loop in the code behind as well.

    foreach (UploadedFile file in RadUpload1.UploadedFiles) 
            { 
                file.SaveAs("c:\\Mydir\\" + file.GetName(), true); 
            } 


    Kind regards,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
2 posts, 0 answered