This is a migrated thread and some comments may be shown as answers.

Upload to Folder based on Extension

1 Answer 53 Views
Upload (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Chase Florell
Top achievements
Rank 1
Chase Florell asked on 22 Jul 2008, 04:42 PM
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/"

1 Answer, 1 is accepted

Sort by
0
Veselin Vasilev
Telerik team
answered on 22 Jul 2008, 05:10 PM
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());  
            }  
            else 
            {  
                file.SaveAs(Server.MapPath("~/uploads/") + file.GetName());  
            }  
        }  
    } 

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

Kind regards,
Veskoni
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Upload (Obsolete)
Asked by
Chase Florell
Top achievements
Rank 1
Answers by
Veselin Vasilev
Telerik team
Share this question
or