Closed (won't fix)
Project:
Drupal core
Version:
4.7.0-beta6
Component:
file system
Priority:
Normal
Category:
Bug report
Assigned:
Reporter:
Created:
31 Mar 2006 at 01:56 UTC
Updated:
4 Apr 2006 at 21:09 UTC
In Drupal's current version, file_check_upload() sets $file->filemime based on $_FILES["edit"]["type"][$source];
In Drupal 4.6, file->filemime was set based on mime_content_type().
In my opinion, the solution adopted in Drupal 4.6 used to be much more reliable. In the way 4.7 is setup, there are many cases in which the MIME type of common uploaded files is not recognized and is set to "unknown/unknown" which does not provide much help for modules such as audio.module that rely on that information...
Would it be possible to change the current version of file_check_upload() so that it matches the way it used to be in 4.6?
Tks in advance,
Leo
Comments
Comment #1
dopry commentedFilemime was removed due to issues with open_basedir. Filemime also was not set based on mime_content_type. Mime content type was simply used for validation.
mime_content_type is also deprecate in php, all of mime-magic is, to be replaced by fileinfo that lives in PECL. see http://us3.php.net/manual/en/ref.mime-magic.php.
The old functionality of mime_content_type in 4.6 would not provide you improve mime recognition. It would only prevent you from uploading improperly identified files, so it wouldn't help modules such as audio, that need to identify mime types.
Comment #2
leoburd commentedHello there,
Thanks for your comments. Unfortunately, I'm new to PHP/Drupal and I'm not sure I understood what you were trying to say.
From my understanding, on the very example that you gave, filemime is being set by mime_content_type():
$file->filemime = mime_content_type($file->filepath);
Moreover, as you said, the usage of mime_content_type() "prevent you from uploading improperly identified files", and that's something that we need in audio.module, otherwise users will be uploading files that, although common, will not be recognized by that module (I've got a bunch of examples where that happened).
Finally, fileinfo seems to be still an experimental function, doesn't it?
Please let me know what you think,
Best,
Leo