Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

ryank30's avatar

Image file upload rules in Request

Hi,

I have a form which takes input data as well as an image file.

I have created a request called "AccountRequest" and I put some validation filters for "file".

public function rules()
{
    return [
        'first_name' => 'required|min:3',
        'last_name' => 'required|min:3',
        'email' => 'required|email|max:255',
        'address' => 'required:min:5',
        'city' => 'required:min:3',
        'postal_code' => 'required:min:6',
        'file' => 'required|image|mimes:jpg,jpeg,png,gif|size:900'
    ];
}

if you look at the line: 'file' => 'required|image|mimes:jpg,jpeg,png,gif|size:900', I am filtering this file according to this criteria.

When I uploaded an image file and submit, I got the error message saying:

LogicException in MimeTypeGuesser.php line 127: Unable to guess the mime type as no guessers are available (Did you enable the php_fileinfo extension?)

Could you help me how to resolve this issue?

Thanks in advance

0 likes
4 replies
SachinAgarwal's avatar

@ryank30 You have to uncomment this line in your php.ini file

extension=php_fileinfo.dll

That is just remove ; from the front of the above line. That will solve the problem.

ryank30's avatar

@SachinAgarwal Thanks for your info.

Would it work on a remote server if I face the same problem? Would you mind showing me how to access the php.ini file on a server? Let's say I have a VPS and access through putty. I am not familiar with all of those commend lines for editing php.ini file...

Thanks in advance.

bashy's avatar

Well... some setups are different, it depends on where your extensions are set. For me personally they're all separate files inside /etc/php5/fpm/conf.d/.

That has files like 10-pdo.ini and includes the .so file.

Please or to participate in this conversation.