Cause of error
This is the verification code I wrote based on the verification component of laravel:
In most cases, it is normal, but when the front end uploads pictures, it occasionally reports the inexplicable error of the file failed to upload. You know, there is no prompt about this error in my code. After many investigations, it can be basically determined that the error is caused by the size of the picture.
First of all, the size of the uploaded file configured by PHP by default is 2m, which can be found in PHP.ini configuration file;
upload_max_filesize=2M
post_max_size=8M
Secondly, the size limit in my laravle validation is also 2M, and laravel by default internally calls the validation based on the configuration of php, so this validation I made did not take effect at all, and the error reported was also called internally by the laravel framework.
The 422 exception thrown by the system function form validation class: The file failed to upload. and by looking at the resources/lang/en/validation file we can see that the actual framework layer is calling the uploaded validation.
Solution:
After modifying the php default configuration and changing the upload image limit size, the image upload problem was successfully solved, I changed it to 20M here, you can modify it according to the actual situation of the project.
upload_max_filesize=20M
post_max_size=20M
Read More:
- PHP large file upload error 413: request entity too large [How to Solve]
- Laravel-admin php artisan admin:install error reporting problem solution
- [Solved] Laravel admin Error: Symfony\Component\Debug\Exception\FatalThrowableError : Class ‘Doctrine\DBAL\Driver\PDOMySql\Driver’ not found
- [Solved] laravel proc_get_status() has been disabled for security reasons
- Laravel5.5 Error: SQLSTATE[42000] Syntax error or access violation 1071 Specified key was too long; max k
- laravel The Process class relies on proc_open, which is not available on your PHP installation.
- [PHP] Solve the limitation of uploading files in nginx php 413 Request Entity Too Large
- [Solved] PHP Error: Warning: file_get_contents(): Failed to enable crypto
- [Solved] file_get_contents(): SSL operation failed with code 1
- PHP file download, download failed, nginx open() nginx / fastcgi_ temp/2/10/0000000102“ failed (13: Permission denied)
- Lack of files in composer installation [How to Solve]
- PHP: How to parse MHT file into HTML
- /www/server/php/56/sbin/php-fpm:error while loading shared libraries:libssl.so.1.0. 0:cannot open shared object file:No such file or directory
- php Error: mail() Failed to connect to mailserver at “localhost” port 25
- [Solved] PHPMailer Failed to Send Email: SMTP Error: Could not connect to SMTP host.
- [Solved] PHPMailer Error: SMTP ERROR: Failed to connect to server: (0)
- php_network_getaddresses: getaddrinfo failed (How to Fix)
- [Solved] Warning: Unknown: Failed to write session data using user defined save handler. (session.save_path:
- [Solved] ‘node’ command failed to start the project, with an error: “unknown database’ mydb ‘”
- composer Failed to decode response: zlib_decode(): data error