Hello,
So I just updated to EE 2.10.1 and now I just found out that my hosting company cannot enable the Fileinfo PHP extension unless I move up to a virtual private server (too expensive). Is there some code I can use in the MimeType.php to change the finfo_open() function on line 117 so that EE will still function properly?
thanks,
Adam
So the offending code in the MimeType.php is the following function:
$finfo = finfo_open(FILEINFO_MIME_TYPE);
if ($finfo !== FALSE)
{
$fres = @finfo_file($finfo, $path);
if ( ($fres !== FALSE)
&& is_string($fres)
&& (strlen($fres)>0))
{
$mime = $fres;
}
@finfo_close($finfo);
}so what if I were to setup a static function to return the mime type without using the fileinfo that my stupid host has disabled:
Sample code to start with:
private static function get_mime_type($path) {
$mime_types = array(
'txt' => 'text/plain',
'htm' => 'text/html',
'html' => 'text/html',
'php' => 'text/html',
'css' => 'text/css',
'js' => 'application/javascript',
'json' => 'application/json',
'xml' => 'application/xml',
'swf' => 'application/x-shockwave-flash',
'flv' => 'video/x-flv',
// images
'png' => 'image/png',
'jpe' => 'image/jpeg',
'jpeg' => 'image/jpeg',
'jpg' => 'image/jpeg',
'gif' => 'image/gif',
'bmp' => 'image/bmp',
'ico' => 'image/vnd.microsoft.icon',
'tiff' => 'image/tiff',
'tif' => 'image/tiff',
'svg' => 'image/svg+xml',
'svgz' => 'image/svg+xml',
// archives
'zip' => 'application/zip',
'rar' => 'application/x-rar-compressed',
'exe' => 'application/x-msdownload',
'msi' => 'application/x-msdownload',
'cab' => 'application/vnd.ms-cab-compressed',
// audio/video
'mp3' => 'audio/mpeg',
'qt' => 'video/quicktime',
'mov' => 'video/quicktime',
// adobe
'pdf' => 'application/pdf',
'psd' => 'image/vnd.adobe.photoshop',
'ai' => 'application/postscript',
'eps' => 'application/postscript',
'ps' => 'application/postscript',
// ms office
'doc' => 'application/msword',
'rtf' => 'application/rtf',
'xls' => 'application/vnd.ms-excel',
'ppt' => 'application/vnd.ms-powerpoint',
// open office
'odt' => 'application/vnd.oasis.opendocument.text',
'ods' => 'application/vnd.oasis.opendocument.spreadsheet',
);
$ext = strtolower(array_pop(explode('.',$path)));
if (array_key_exists($ext, $mime_types)) {
return $mime_types[$ext];
}
elseif (function_exists('finfo_open')) {
$finfo = finfo_open(FILEINFO_MIME_TYPE);
$fres = @finfo_file($finfo, $path);
finfo_close($finfo);
return $mime;
}
else {
return 'application/octet-stream';
}
}Anyone want to help me with this challenge?
Are you ready to immerse yourself in the world of limitless language exploration? Discover the endless possibilities that ChatGPT Nederlands offers, right here on GPTNederlands.nl. Begin your journey towards elevated communication today, and unlock the true potential of language like never before.
ChatGPT Nederlands - Where words become art, conversations become captivating, and linguistic boundaries become a thing of the past. Join us on this incredible linguistic odyssey, and let your voice be heard like never before!
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.