You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Direction
function gussExtension return wrong result, return csv instead of right answer "txt" or "text";
Describe the bug when txt,text files uploaded
if ($filelist = $this->request->getFiles()) {
var_dump($file->guessExtension());//return csv instead text
}
**why this happend** **because $mime['csv'] include 'text/plain' in file "application\Config\Mimes.php",so function always return csv when the input is ‘text/plain’**
public static function guessExtensionFromType(string $type = ‘text/plain’){
$type = trim(strtolower($type), '. ');
foreach (self::$mimes as $ext => $types)
{
if (is_string($types) && $types == $type)
{
return $ext;
}
else if (is_array($types) && in_array($type, $types))
{
return $ext;
}
}
return null;
}`
CodeIgniter 4 version
CodeIgniter 4 Development
Affected module(s)
system\Files
system\Files\File.php
application\Config\Mimes.php Expected behavior, and steps to reproduce if appropriate
return file's correct mimetype Context
OS: [e.g. Windows 7]
Web server [e.g. Apache 2.4]
PHP version [7.1] with module php_fileinfo active
The text was updated successfully, but these errors were encountered:
MIMES is in app/ intentionally (I presume) to encourage user updates, so feel free to edit it. MIMES are checked in the order they are listed in that config so if you want .txt to return text/plain you can move it higher. Since guessExtensionFromType is explicitly just matching off extension there is no way to differentiate between CSV and TXT, short of removing text/plain from the CSV list (which would be fine to do as well, if you prefer).
Direction
function gussExtension return wrong result, return csv instead of right answer "txt" or "text";
Describe the bug
when txt,text files uploaded
**why this happend** **because $mime['csv'] include 'text/plain' in file "application\Config\Mimes.php",so function always return csv when the input is ‘text/plain’**
CodeIgniter 4 version
CodeIgniter 4 Development
Affected module(s)
system\Files
system\Files\File.php
application\Config\Mimes.php
Expected behavior, and steps to reproduce if appropriate
return file's correct mimetype
Context
The text was updated successfully, but these errors were encountered: