I have extensions pdf and htm as the allowable files types within my form.

If I try to upload a .htm file (eg example.htm) I get the error below.
---------------------------------------------------------------
# Files with the extension txt are not allowed. Please upload a file with an extension from the following list: pdf htm
---------------------------------------------------------------

If I then allow the txt extension, the file is then renamed to example.htm.txt.

Any advice on how to fix this issue.

Thanks in Advance
Stephen

Comments

jpetso’s picture

Status: Active » Fixed

This is a security measure of Drupal core, filefield has no influence on that (and shouldn't have). The file_check_upload() function in includes/file.inc appends ".txt" to certain file types. Actually, I believe that .htm files are only renamed this way in Drupal 4.7, as the corresponding check in Drupal 5 is much more stringent and doesn't cover all files that are somehow text.

Proper solution: upgrade to Drupal 5.
Quick-and-dirty solution: replace the check in file_check_upload() with the one from Drupal 5, if you know how to do it and know about the implications of modifying Drupal core.

spjsche’s picture

Thanks for the quick response, I shall investigate and see which is the better option.

Thanks for your time.

Stephen

Anonymous’s picture

Status: Fixed » Closed (fixed)

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