Upload to Folder based on Extension

Thread is closed for posting
2 posts, 0 answers
  1. Chase Florell
    Chase Florell avatar
    257 posts
    Member since:
    Apr 2005

    Posted 22 Jul 2008 Link to this post

    Is there a way for RadUpload to upload to a specific folder based on the file extension?

    If .jpg .gif .png
    go to "~/Assets/Images/"

    If .mov .avi .wmv
    go to "~/Assets/Videos/"

    If .mp3 .wma
    go to "~/Assets/Music/"
  2. Veselin Vasilev
    Veselin Vasilev avatar
    2992 posts

    Posted 22 Jul 2008 Link to this post

    Hello Chase Florell,

    Yes, this is possible.

    Here is how you can do this:

        protected void Button1_Click(object sender, EventArgs e)  
            foreach (UploadedFile file in RadUpload1.UploadedFiles)  
                if (file.GetExtension().ToLower() == ".gif")  
                    file.SaveAs(Server.MapPath("~/images/") + file.GetName());  
                    file.SaveAs(Server.MapPath("~/uploads/") + file.GetName());  

    Note: You should not set the TargetFolder property of the upload.

    Kind regards,
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
Back to Top