user2864496
user2864496

Reputation: 107

Preventing Renaming file extension in Telerik RadFileExplorer

Hi I'm working with Telerik Radfileexplorer. I'm using this to upload only pdf documents. But after uploading the documents users can rename them. The control is allowing the users to rename file extension pdf aslo then if they change extension from pdf to some other then the file disappears. I tried to stop the behavior by following one of the post from Telerik forums but still the file is disappearing. The code and the form link are as follows.

http://www.telerik.com/forums/renaming-file-disallow-extensions-cancel-move

function explorerMove(explorer, args)
{
    //check if the event is fired by Rename command
    if (args.get_newPath().search("/") < 0) {
        if (!args.get_item().isDirectory()) { //check if the renamed item is file or folder

            var orgExt = args.get_path().substring(args.get_path().lastIndexOf("."));
            var newExt = args.get_newPath().substring(args.get_newPath().lastIndexOf("."));

            if (orgExt != newExt) {
                alert("Changing the file extension is not allowed");
                args.set_cancel(true); //cancel further execution of the command
            }
        }
    }
}

Here even though the default behavior is canceled by using args.set_cancel(true); the file extension is still changing and file is disappearing. I thought of way to assign old path to new path in the if condition if(orgExt != newExt) but i don't know how to do it.

Upvotes: 0

Views: 676

Answers (1)

rdmptn
rdmptn

Reputation: 5601

It seems this feature is supported out of the box with a property:

<telerik:RadFileExplorer runat="server" ID="FileExplorer1">
    <Configuration AllowFileExtensionRename="false"></Configuration>
</telerik:RadFileExplorer>

Upvotes: 1

Related Questions