Greetings,
I've come across a problem that has me perplexed. I've installed drupal 4.6.3 in XAMPP for Windows. Drupal is set to accept .,mp3 uploads through the administer>>settings>>uploads line that reads "jpg jpeg gif png txt html doc xls pdf ppt pps mp3 wma wmv wav".

However, when I try to upload a variety of files to the server the MIME type gets whacked and the files ends up on the server as a .txt file. Jpegs are fine, Excel, Powerpoint and most importantly mp3s get messed up. the mime.conf file has been edited to include audio/x-mpeg as well as audio/mp3 yet the problem persists.

Please, I've searched through the forums and have not discovered anyone with a solution. Would you be so kind as to assist?

Jym

Comments

JymBrittain’s picture

After some experimentation, it turns out the filename is getting mungled. When the attached file is saved on the server it gets .txt added to the name. When the same attachment.mp3.txt gets downloaded it gets .html added, turning it into attachment.mp3.txt.html. Stripping off the .txt.html returns the file to a playable mp3, however this is not an acceptable solution as we're dealing with some pretty novice users. Anyone have any ideas?

technology4teachers.com

JymBrittain’s picture

In the case I issued this plea for help for I was using XAMPP for Windows. This application package had the mime magic module for apache commented out in the httpd.conf file. Furthermore the magic conf file included did not have an entry for mp3s. After modifying the httpd.conf file to include the magic.mime module I added the mp3 mime info to the magic conf file. I restarted the apache server and mp3s can now be uploaded and downloaded with no problem.

Excel and Powerpoint files still get whacked. However, since this installation is meant primarily as a podcast site for educators at the college I work for, this isnt a problem...yet.

technology4teachers.com

tjp144’s picture

How did you add the mp3 mimie to the magic conf file?

I am using Drupal 4.7 beta 4 on Red Hat Enterprise Linux 4

thanks
-Tim

bmargulies’s picture

I'm using LAMP set up on Ubuntu and I hit the same .txt crazyness with pdf files. So, I went and enabled (I thought) the mime_magic module, but while it changed the error message it didn't really change the behavior. Did you discover a reliable way to prove that the mime stuff was, in fact, active in Apache?

coofercat’s picture

I found this (about Horde): http://wiki.horde.org/MimeMagic?Horde=89068dd5308a7d09bbbe9682288ad75&re...

Which essentially says to install a couple of things and configure a MIME magic file in /etc/php.ini. After doing all this, I couldn't get it working, and then stumbled over this: http://uk2.php.net/manual/en/function.mime-content-type.php#50756

...which says to put the following in your php.ini:
[mime_magic]
mime_magic.debug = On
mime_magic.magicfile = "/usr/share/file/mime.magic"

Note: I found the magic file in /etc/httpd/conf and in /usr/share/magic.mime didn't work properly (causing lots of startup errors in error_log). I also find that switching debug off stops the mime magic working.

Incidentally, those of a PHP hacking nature, the code that does the checks is in includes/file.inc and basically says:

if (function_exists('mime_content_type')) {
$file->filemime = mime_content_type($file->filepath);
if ($file->filemime != $_FILES["edit"]["type"][$source]) {
watchdog('file', t('For %file the system thinks its MIME type is %detected while the user has given %given for MIME type', array('%file' => theme('placeholder', $file->filepath), '%detected' => theme('placeholder', $file->filemime), '%given' => theme('placeholder', $_FILES['edit']['type'][$source]))));
}
}
else {
$file->filemime = $_FILES["edit"]["type"][$source];
}

...in other words, if your PHP has mime_content_type, then make sure it does what it's supposed to! (Which may help you diagnose/fix the problem without any Drupal or other issues involved).

larry moore’s picture

FYI,
Updating mime_magic.magicfile in php.ini did not work for me.
This article got me up and running.
http://drupal.org/node/41561

Not sure if removing code is the best solution. I was fine with 4.7 but when I updated to 4.7.2, file uploads started adding ".txt".

-lgm

brainlock’s picture

I updated my php.ini with the correct location of the magic file... seems there are different versions of magic files dispersed throughout...

http://us3.php.net/mime_magic