On Windows, the fileinfo extension is usually already included with PHP—you normally just need to enable it in php.ini. Here is the straightforward way to do it.
1. Find your php.ini
Open a Command Prompt and run:
php --ini
You will see something like:
Loaded Configuration File: C:\php\php.ini
Open that php.ini file in a text editor (e.g., Notepad++ or Notepad).
2. Enable the extension
Search for the line:
;extension=fileinfo
Remove the semicolon ; so it becomes:
extension=fileinfo
Save the file.
3. Restart your web server
If you are using:
- XAMPP → restart Apache from the control panel
- WampServer → restart all services
- IIS → restart IIS
If you only use PHP from the command line, just close and reopen the terminal.
4. Verify it works
Run:
php -m
You should see:
fileinfo
✅ Quick test in PHP
Create test.php:
<?php
$finfo = new finfo(FILEINFO_MIME_TYPE);
echo $finfo->file("test.jpg");
?>
Run:
php test.php
It should output something like image/jpeg.