Rename or save as when uploading file

2 posts, 0 answers
  1. Atlas
    Atlas avatar
    97 posts
    Member since:
    Jun 2009

    Posted 04 Oct 2010 Link to this post

    I would like to add a method to strip out special characters from a filename when it is uploaded, but I am not sure where to put the code. With the regular upload control you can use the saveas dialoge, but I am not sure where to implement this code in the file explorer control. My code looks like this:

    if (e.Command == "UploadFile")
                    RadFileExplorer explorer = sender as RadFileExplorer;
                    if (explorer != null)
                        int ItemId = Convert.ToInt32(explorer.Attributes["ItemId"]);
                        string[] aFolder = e.Path.Split('/');
                        foreach (UploadedFile file in explorer.Upload.UploadedFiles)
  2. Dobromir
    Dobromir avatar
    1633 posts

    Posted 06 Oct 2010 Link to this post

    Hi Nano,

    Fiko already answered your support ticket on the subject. For convenience I will paste his answer here as well.

    The best way and the best place to do this is inside the FileBrowserContentProvider's SaveFile method. In your case I recommend you to subclass the default provide which ships with radFileExplorer - Telerik.Web.UI.Widgets.FileSystemContentProvider and override its SaveFile method in order to achieve the desired result:
    public override string StoreFile(UploadedFile file, string path, string name, params string[] arguments)
        return base.StoreFile(file, path, name, arguments);

    Please note that you need to return the virtual path of the currently saved file. Then you can set the new provider to the RadFileExplorer control.

    I hope this helps.

    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top