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

Can we have DisallowedFileExtensions?

2 Answers 57 Views
AsyncUpload
This is a migrated thread and some comments may be shown as answers.
Lenny_shp
Top achievements
Rank 2
Lenny_shp asked on 29 Sep 2011, 10:39 PM
I just wanted to exclude .exe, .com., .bat., zip but allow most of extensions.   With .xsl becoming .xslm, .xslx it is a bit of a maintenance to keep adding to the AllowedFileExtensions.

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 04 Oct 2011, 06:04 AM
Hello Lenny,

Check the following forum thread which shows how to achieve the client side file-extension validation.
DisAllowedMimeTypes and DisAllowedFileExtensions

Thanks,
Princy.
0
Dimitar Terziev
Telerik team
answered on 04 Oct 2011, 09:42 AM
Hi Leonid,

In general there is no build in functionality for setting not allowed files extensions. You could however try to manually filter the files and cancel the upload if a file with specific extension is being uploaded. In order to achieve this you should subscribe on the client-side OnClientFileUploading event and use the following implementation of the event handler function:
<script type="text/javascript">
 
    function OnClientFileUploading(sender, args) {
 
        var fileName = args.get_fileName();
        var fileExtension = fileName;
 
        var lastIndex = fileName.lastIndexOf('.');
        fileExtension = fileName.substring((lastIndex + 1), (fileName.length));
 
        if (fileExtension == "zip") {
 
            args.set_cancel(true);
        }
    }
</script>

The above suggested solution will not upload files with zip extension.

Best wishes,
Dimitar Terziev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Tags
AsyncUpload
Asked by
Lenny_shp
Top achievements
Rank 2
Answers by
Princy
Top achievements
Rank 2
Dimitar Terziev
Telerik team
Share this question
or