Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to enable php_fileinfo extension in PHP?

My Laravel app can't validate uploaded images. It returns this error message:

Unable to guess the mime type as no guessers are available (Did you enable the php_fileinfo extension?)

Laravel error message

I know enabling php_fileinfo.dll/php_fileinfo.so at php.ini fixes it. But I don't have access to my remote server's php.ini file.

So I thought is there any other way to enable it? And how? Maybe I can use PHP's ini_set() methods? I tried using it like:

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

But it doesn't work.

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

As Laravel's default, my .htaccess file is:

<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 should you put such additionals in there?

like image 623
doncadavona Avatar asked Mar 11 '15 08:03

doncadavona


People also ask

What is Fileinfo PHP extension?

FileInfo functions module can try to guess a content type and encoding of a file by looking for certain magic byte sequences at a specific position within a file. While it's not a bulletproof approach, the heuristics used to do a very good job. Before PHP 5.3.


2 Answers

create own php.ini file in root folder of your directory.

example if you are making changes on a server then it should be inside the public.html folder.

create file name php.ini it will override the settings. just add in the file

extension=php_fileinfo.dll
like image 163
Sayed Mohd Ali Avatar answered Oct 01 '22 16:10

Sayed Mohd Ali


If you are using WHM, go to Easy Apache, search fileinfo (In the search field), and enable it ( I found for php5.5, php5.6 and php.7.0.

And click on "Review" left tab.

Then click on provision, and done. It works for me ( I spend 3 hours trying install/enable fileinfo)

like image 23
Juan Aguillón Avatar answered Oct 01 '22 16:10

Juan Aguillón