This problem has been discussed extensively (see "Flexinode Files getting .txt extensions added to them" and "why does it save in .txt?"). The modification necessary to solve this issue is contained in this patch.

CommentFileSizeAuthor
file.inc_4.patch1.06 KBdarren oh

Comments

drumm’s picture

Status: Needs review » Closed (works as designed)

Commenting out code is not an acceptable substitute for removing it.

That particular code is there for security reasons. Uploaded files with certain extensions can be executed by some servers, so the extensions must be changed.

darren oh’s picture

Status: Closed (works as designed) » Needs work

Actually, this is not by design. It is the result of depending on an unreliable PHP feature.

darren oh’s picture

Title: All File Extensions Changed to .txt » .txt added to all file extensions
Status: Needs work » Closed (duplicate)

After some more investigation, I found that file type detection was completely removed because it was not working reliably. See CVS commit 26881.

By the way, "all file extensions" includes .jpg, .html, .png, .pdf -- everything.

The problem is that PHP's file type checking never worked well, is no longer maintained, and will be replaced in the future. It has been deprecated and should not be used.

This problem was discussed in issue 43220 and the decision was made to remove file type checking until someone offered a better solution. However, the code that assigns the extension .txt to any undetected file type was not removed. I think it may have been overlooked, so I'm going to reopen the original issue and mark this one as a duplicate.