I'm validating a request as an image, but crashes saying:
"Unable to guess the MIME type as no guessers are available (have you enable the php_fileinfo extension?)".
In php.ini
I don't have a extension=php_fileinfo
, but I do have a extension=fileinfo
uncommented line (I see Lumen put this and other dependencies without the 'php_'
). I also try adding extension=php_fileinfo
, but when I restart Apache from XAMPP it crashes because it doesn't find that dependency. What should I do?
The code:
function updateProfilePicture(Request $request) {
$this->validate($request, [
'image' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:2048'
]);
//...
The php.ini section where fileinfo dependency is:
;;;;;;;;;;;;;;;;;;;;;;
; Dynamic Extensions ;
;;;;;;;;;;;;;;;;;;;;;;
; If you wish to have an extension loaded automatically, use the following
; syntax:
;
; extension=modulename
;
; For example:
;
; extension=mysqli
;
; When the extension library to load is not located in the default extension
; directory, You may specify an absolute path to the library file:
;
; extension=/path/to/extension/mysqli.so
;
; Note : The syntax used in previous PHP versions ('extension=<ext>.so' and
; 'extension='php_<ext>.dll') is supported for legacy reasons and may be
; deprecated in a future PHP major version. So, when it is possible, please
; move to the new ('extension=<ext>) syntax.
;
; Notes for Windows environments :
;
; - Many DLL files are located in the extensions/ (PHP 4) or ext/ (PHP 5+)
; extension folders as well as the separate PECL DLL download (PHP 5+).
; Be sure to appropriately set the extension_dir directive.
;
extension=bz2
extension=curl
extension=fileinfo
extension=gd2
extension=gettext
Maybe is it related to that disclaimer about how to set the dependencies directives? (I'm not sure because extension=fileinfo
was already in the file as a default)
I'm using windows 10 and I found the file in C:\xampp\php\ext\php_fileinfo.dll
I found the problem. I had another php.ini file with the commented line ;extension=fileinfo
in C:\php\php.ini
(the one I was opening was in C:\xampp\php\php.ini
). Now I restarted Apache and it's working!