I've added server side mime detection to file field. This function attempts to use fileinfo, the fileutils file binary, and browser provided mime, then tries the extension if the filemime isn't set or is application/octet-stream since it seems to be the mime type that unknown video types get in a lot of places.

It properly detects wmv/wma files on my laptop...

Comments

dopry’s picture

Status: Active » Needs review
StatusFileSize
new4.34 KB

Opps... forgot a default mime setting should everything fail...

dopry’s picture

StatusFileSize
new4.34 KB

Opps... forgot a default mime setting should everything fail...

jpetso’s picture

Looks good from a coding point of view, however I guess I should test it on my systems before urging you to commit :)

Ogg will be difficult if you can't determine its exact type by mimetypes, as the extension is usually .ogg for both audio and video... but that's not something that should keep this patch from being included.

jpetso’s picture

Additional note: it might be worth a try to get this into Drupal 7, would be great to have more reliable mimetype detection all over the place.

dopry’s picture

Status: Needs review » Fixed

I added a dependency on mimedetect and use it instead.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.

gaellafond’s picture

Just in case someone else still have that problem:

There is an improved MimeType detection on the new version of the FileField module so this patch is no longer required. If you want to enable the MimeType detection, you have to install and enable the MimeDetect module:
http://drupal.org/project/mimedetect

You don't need any configuration, FileField will automatically use the module when it is enabled.

NOTE: This is useful to avoid malicious file to be upload by changing the file extension (like virus.exe uploaded after renaming it to virus.exe.gif).