I've got a module that let users upload files, and everything works as long as the files are in the standard array of allowed extensions. I've tried using file_validate_extensions()
, but this doesn't seem to change anything.
This is the code I'm using to upload now (the docx extension is added to the standard allowed ones, but it doesn't seem to get picked up):
$fid = $form_state['values']['attachment'];
$file = file_load($fid);
if ($file != null) {
file_validate_extensions($file, "jpg jpeg gif png txt doc xls pdf ppt pps odt ods odp docx");
$file->status = FILE_STATUS_PERMANENT;
file_save($file);
}
file_validate_extensions()
; as the function just checks if the extension is one of the extensions contained in the string passed as argument, and it returns an array containing an error string, if you don't use the returned value is perfectly useless to call the function.