mirror of
https://github.com/prasathmani/tinyfilemanager.git
synced 2025-03-15 20:49:48 +01:00
Update tinyfilemanager.php (#568)
fm_get_file_mimes() was causing errors for unknown extensions as it was causing an error as array element was not defined and return value was never checked. According to https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types and several other resources, application/octet-stream is the default value for all other cases. An unknown file type should use this type. I put a check in there to use that by default so a valid value is always returned. It might be useful to replace this function with the built-in PHP function mime_content_type() but that adds some additional dependencies as it does not always work out of the box with PHP.
This commit is contained in:
parent
e843adcf0b
commit
8158333d93
@ -2945,6 +2945,10 @@ function fm_get_file_mimes($extension)
|
||||
$fileTypes['php'] = ['application/x-php'];
|
||||
$fileTypes['html'] = ['text/html'];
|
||||
$fileTypes['txt'] = ['text/plain'];
|
||||
//Unknown mime-types should be 'application/octet-stream'
|
||||
if(empty($fileTypes[$extension])) {
|
||||
$fileTypes[$extension] = ['application/octet-stream'];
|
||||
}
|
||||
return $fileTypes[$extension];
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user