How to enable php_fileinfo extension in PHP?

My Laravel application cannot check uploaded images. It returns this error message:

It is impossible to guess the mime type, since no guesswork is available (do you enable the php_fileinfo extension?)

Laravel error message

I know that including php_fileinfo.dll / php_fileinfo.so in php.ini fixes it. But I do not have access to the php.ini file of the remote server .

So, I was thinking, is there any other way to enable it? And How? Maybe I can use PHP methods ini_set()? I tried using it like:

ini_set('extension', 'php_fileinfo.so');

But that will not work.

I also read that you can override php.ini settings using .htaccess files. But how?

Like Laravel by default, my .htaccess file:

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>

    RewriteEngine On

    # Redirect Trailing Slashes...
    RewriteRule ^(.*)/$ /$1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

How can you add such add-ons there?

+4
4

.htaccess, ,

php_value extension=php_fileinfo.dll

php_admin_flag extension=php_fileinfo.dll
+1

, .

$image_size_info = @getimagesize($filename); //surpress errors(@) if not image
if( empty($image_size_info) ) $mime_type = "";
else $mime_type = @image_type_to_mime_type( $image_size_info[2] );

//safety for all cases:
if( empty($mime_type) ) $mime_type = "";

if(  strpos($mime_type, "image/") === false  )
{
//not an Image !
} 
else 
{
  //proceed file upload
}

, → > https://github.com/thephpleague/flysystem/commit/0ec96b1104e57bfcf0e40d6169c8e203b7942b34

0

cpanel,

PHP

FileInfo

.

0

php.ini .

, , public.html.

php.ini, .

extension=php_fileinfo.dll
0

All Articles