I am trying to create a file validator for .csv uploads. This is my code that works at allowing csv uploads (which are disallowed by default):
$validators['file_validate_extensions'] = array('csv'); $file = file_save_upload('csv', $validators);
However, when I try to upload another file (in this case fizzbuzz.py) I get this error:
For security reasons, your upload has been renamed to fizzbuzz.py.txt.
How can I change this to being and out right error when a non csv file is uploaded?
EDIT: Did some more testing. This only occurs for my
.py file. Files with a
.png extension get rejected and are not uploaded.
EDITx2: Okay, so it also rejects
.txt file extensions. It looks like Drupal does not validate two letter file extensions in the same way it validates three(+) letter file extensions.