Try Now
More in this section

Forums / Developing with Sitefinity / Upload photo - limit size of image

Upload photo - limit size of image

4 posts, 0 answered
  1. Mark
    Mark avatar
    86 posts
    08 Feb 2010
    29 Mar 2011
    Link to this post

    I have a front end control that allows the user to upload their user photo (Profile.Photo)
    This goes into a image library

    To stop people with digital camera trying to upload a 5mb file, do you have any code/built in features into the



    RadUploder that will resize the "image size" and "filesize" (and keep proportions)


    I'm sure I saw some code one on the forum but cannot find it anywhere

  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    12 Sep 2017
    29 Mar 2011
    Link to this post
    Hi Markus,

    I believet that that this is what you are looking for


    Best wishes,
    Ivan Dimitrov
    the Telerik team
  3. Mark
    Mark avatar
    86 posts
    08 Feb 2010
    29 Mar 2011
    Link to this post
    Thank you Ivan!
    Yes that was the article

    Could i just clarify a couple of things
    This code looks like it resizes all images to the global.asax set dimension (if they are above a certain size)
    this is great and useful for any silly large images

    What i'd also like to do, using the code you have provided here:

    is to restrict the height dimension
    i.e. set it to the same height as the default sitefinity avatar:


    And keep constrain the width proportions

    can the code you provided in the link above be changed to acheive this, or can i only

    I did try and use:
    foreach (Telerik.Web.UI.UploadedFile file in RadUploder.UploadedFiles)
        file = Telerik.Cms.Engine.ImagesHelper.GenerateThumbnail(200, 200, file, true, true);

    however, i get the error
    cannot convert from 'Telerik.Web.UI.UploadedFile' to 'System.Drawing.Image' 

    could you point me in the right direction please?
  4. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    01 Feb 2016
    31 Mar 2011
    Link to this post
    Hello Markus,

    You will have to get the FileStream of the uploaded file and then create an Image object from the FileStream. This forum post contains a sample how to create image from file stream.

    All the best,
    Radoslav Georgiev
    the Telerik team
Register for webinar
4 posts, 0 answered