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

Compare mime type againt file extension

1 Answer 328 Views
Upload (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Foppa
Top achievements
Rank 1
Foppa asked on 18 Feb 2013, 04:05 PM

How can I validate that the file I have uploaded has right mime type if compared with the file extension?

I want to support all browsers. It means well that I must do the validation on the server. Or?
And how should I do?

Right now I use RadUpload and validates against the file extensions, it works well. But like I say I also want to make sure that the file extension matches the mine type.

Grateful for the tips!
Best regards,
Foppa

1 Answer, 1 is accepted

Sort by
0
Plamen
Telerik team
answered on 21 Feb 2013, 03:28 PM
Hello Foppa,

 
You can set the AllowedMimeTypes programmatically as it is done in the code behind in this on-line demo but different browsers serve different MIME types for the same files and as it is explained here 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.

Hope this will explain the issue.

Greetings,
Plamen
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
Upload (Obsolete)
Asked by
Foppa
Top achievements
Rank 1
Answers by
Plamen
Telerik team
Share this question
or