A S M Saief
A S M Saief

Reputation: 310

Laravel Image validation not working when I try to upload ai or psd file

Laravel Image validation not working. When I try to upload ai or PSD file it's showing error:

Illuminate \ Http \ Exceptions \ PostTooLargeException No message

Also not working when trying to upload a 3Mb image file.

$this->validate($request, [
      'company_name' => 'required',
      'logo' => 'mimes:jpeg,jpg,png|max:1024|image',
      'address' => 'required',
      'phone' => 'required|numeric',
      'currency_code' => 'required',
      'vat_rate' => 'required|numeric'
]);

Upvotes: 2

Views: 619

Answers (2)

Iftikhar uddin
Iftikhar uddin

Reputation: 3182

Try using size validation Rule instead of max, from the docs:

size:value

The field under validation must have a size matching the given value. For string data, value corresponds to the number of characters. For numeric data, value corresponds to a given integer value. For an array, size corresponds to the count of the array. For files, size corresponds to the file size in kilobytes.

$this->validate($request, [
      'company_name' => 'required',
      'logo' => 'mimes:jpeg,jpg,png|size:1024|image', 
      'address' => 'required',
      'phone' => 'required|numeric',
      'currency_code' => 'required',
      'vat_rate' => 'required|numeric'
]);

Upvotes: 1

Udhav Sarvaiya
Udhav Sarvaiya

Reputation: 10071

Default file upload size is 2MB

Open the php.ini file. Find these lines in the php.ini file and replace it following numbers: upload_max_filesize = 64M Save the changes and try uploading the file again. You will now get success.

You can find the path of your PHP configuration file in your xampp/php/php.ini(Windows User) file And don't forget to restart your server

Upvotes: 3

Related Questions