Skip to content

Commit baeaad2

Browse files
committed
fix(upload): add PHP 8.1+ compatibility for finfo_close() deprecation. finfo_open() returns an finfo object (not a resource) since PHP 8.1, which is automatically freed when it goes out of scope.
Fixes #34.
1 parent 91bb1b5 commit baeaad2

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

system/libraries/Upload.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1231,7 +1231,10 @@ protected function _file_mime_type($file)
12311231
if ($finfo !== FALSE) // It is possible that a FALSE value is returned, if there is no magic MIME database file found on the system
12321232
{
12331233
$mime = @finfo_file($finfo, $file['tmp_name']);
1234-
finfo_close($finfo);
1234+
if (PHP_VERSION_ID < 80100)
1235+
{
1236+
finfo_close($finfo);
1237+
}
12351238

12361239
/* According to the comments section of the PHP manual page,
12371240
* it is possible that this function returns an empty string

0 commit comments

Comments
 (0)