By forrestn on
For some reason, flexinode keeps adding a .txt file extension onto my files, for example movie.mov.txt
Can I get rid of this? Also, certain files don't have this problem. .pdf files work. it doesn't seem to have anything to do with my uploads module either, because both .mov and .pdf files are allowed.
Comments
PHP's mime_content_type
I've come across this problem before--it's due to the malfunction of PHP's mime_content_type function.
If PHP's mimetype module is not configured correctly (contact your host), mime_content_type will always return text/plain as a type for any unrecognized file. Drupal then gives the file a ".txt" extension (I don't agree with this...).
You're going to have to change Drupal's file.module to change this behavior. In includes/file.inc, you need to comment out the block:
__
My Drupal websites: Personal home page | Rhombic Networks: specialized Drupal application hosting
thanks, that worked
thanks, that worked perfectly.
I have submitted this
I have submitted this modification as a patch in issue 74542.
as commented somewere...
Better than patching, simply add this section to your php.ini (if you can modify your server configuration):
[mime_magic]
mime_magic.magicfile = "/etc/magic"
Not guaranteed to work
PHP cannot handle a full, system magic file (see documentation), and it needs a crippled one instead. If it cannot be parsed (very likely) it will just ignore it, displaying the symptoms mentioned in this thread.
__
Personal home page | Rhombic Networks: Drupal-friendly web hosting
I got this to work.
FYI,
Updating mime_magic.magicfile in php.ini did not work for me.
I removed the code you suggested. 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".
cross-post from here
-lgm
Absolutely NOT the best solution
It is absolutely not the best solution, but the only one I've found to work reliably.
Long-term, Drupal should not use PHP's mime functions (which are not really maintained anymore, which is why problems like this exist) and use instead the MIME functions provided by PEAR. I intend to write a patch one day but having Drupal depend on PEAR is not a change I see the core devels being open to.
__
Personal home page | Rhombic Networks: Drupal-friendly web hosting