After enabling the fileinfo extension and restarting Apache, it still doesn't load

I want to use the fileinfo extension in PHP (5.5). (On localhost (Windows) using XAMPP)

So, I went to php.ini and commented extension=php_fileinfo.dll, then restarted apache, even tried to restart the whole PC.

But when I try to use it, I still get the function / class does not exist ... (procedural / objective)

When I looked at the php_info () page, there are "fileinfo" listed , but only among the "Module Authors" table - and, I suppose, not enaugh - is this?

Does anyone know how to solve this?

PS: I checked php.ini for the magic path, and there is. mime_magic.magicfile = "\xampp\php\extras\magic.mime"
However, such a file is missing from the entire xampp folder structure ... - maybe this is the reason why it does not load? Where can I download this file?

Many thanks!

PS2: A solution for others with the same problem who want to upload only images:

  $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
  }
+4
source share

Source: https://habr.com/ru/post/1545417/


All Articles