0

How can I validate telerik radupload for mimeTypes -> mean Prevent Change Extension by users!
in both Client and Server sides!
my radupload is like this :

    <telerik:RadUpload ID="RadUpload" runat="server" EnableEmbeddedSkins="False" Skin="BlackByMe" AllowedFileExtensions=".txt" AllowedMimeTypes="text/plain"
        ControlObjectsVisibility="ClearButtons" Width="325px">
    </telerik:RadUpload>  

as you can see the AllowedFileExtensions is txt.
But, how can I prevent someone from changing a zip file's extension to txt and upload it.
There are many methods out there for Telerik RadUpload Validation Such As FileExtension-FileSize-Empty RadUpload, but what about validating the real MiMeType?

thanks in advance

Ozair Kafray
  • 13,351
  • 8
  • 59
  • 84
SilverLight
  • 15
  • 1
  • 5

1 Answers1

0

Property AllowedMimeTypes should work.

The AllowedMimeTypes property lists the valid MIME types for uploaded files. When the AllowedMimeTypes property is set, RadUpload automatically validates the MIME types of selected files, moving any files with disallowed extensions to the InvalidFiles collection.

Check this note

RadUpload does not determine the mime-type using only the file extension. For example if you try to upload a text file that has the extension ".JPG", it is still uploaded with text/plain mime-type.

<telerik:radupload id="RadUpload1" runat="server" 
    allowedmimetypes="application/x-compressed,application/x-zip-compressed,application/zip,multipart/x-zip"
    maxfilesize="1000000" allowedfileextensions=".zip" 
    targetfolder="~/My Files" />
Claudio Redi
  • 67,454
  • 15
  • 130
  • 155
  • thanks for the answer. but i want to show a message to that user. is there a way to use CustomValidator for doing that -> both server and clietn sides. clietn side is better. – SilverLight Jun 07 '12 at 14:12
  • also as you see i set that property in my radupload. but that zip file (changed to txt extesion) is still valid. why? – SilverLight Jun 07 '12 at 14:13
  • @SilverLight: this should show a message to the user. I can't test it right now but I'll try to do it later. According the documentation `AllowedMimeTypes` should be enough. If that's not the case you should ping telerik support to see what's going on. – Claudio Redi Jun 07 '12 at 14:17
  • The link is on my answer http://www.telerik.com/help/aspnet-ajax/upload-integrated-validation.html – Claudio Redi Jun 07 '12 at 14:23