Configuration for File Upload Limits
Problem
When trying to upload images larger than 2-4MB, you may receive an error message like “validation.uploaded” even though Laravel’s validation allows up to 5MB.Root Cause
This issue is typically caused by PHP server limits being lower than Laravel’s validation limits. PHP has its own upload size restrictions that must be configured separately.Solution
1. Configuration Files Updated
We have automatically updated the following files:/public/.htaccess
/public/.user.ini
2. If the Above Doesn’t Work
If you still experience upload issues, you may need to configure PHP directly on your server.For Apache with mod_php:
Edit your server’sphp.ini file (usually located at /etc/php/8.x/apache2/php.ini):
For Nginx with PHP-FPM:
Edit your PHP-FPM pool configuration (usually at/etc/php/8.x/fpm/pool.d/www.conf):
php.ini file at /etc/php/8.x/fpm/php.ini with the same values.
After editing, restart PHP-FPM and Nginx:
For Shared Hosting:
If you’re on shared hosting, you may need to:- Contact your hosting provider to increase the limits
- Use the
.user.inifile we’ve created (some hosts support this) - Or use a
php.inifile in your public directory (check with your host if this is supported)
3. Verification
To verify your PHP configuration, create a temporary PHP file:upload_max_filesize: should be at least 10Mpost_max_size: should be at least 10Mmax_execution_time: should be at least 300memory_limit: should be at least 256M
4. Laravel Configuration
The Laravel validation rules have been updated in:/app/Http/Controllers/Eventos/EventosController.php
5. Image Dimensions Updated
Header and footer image placeholders have been updated to support larger heights:- Header: 1200×600 (previously 1200×300)
- Footer: 1200×600 (previously 1200×100)
6. Error Messages Translated
All validation error messages are now properly translated to Spanish in:/resources/lang/es/validation.php/lang/es/validation.php
Testing
After making these changes:- Clear Laravel’s cache:
php artisan cache:clear - Clear config cache:
php artisan config:clear - Restart your web server
- Try uploading an image between 4-5MB
Troubleshooting
If uploads still fail:- Check your server’s error logs
- Verify PHP configuration with
phpinfo() - Check disk space on your server
- Verify folder permissions (storage folder should be writable)
- Check if there are any Nginx/Apache body size limits:
- For Nginx:
client_max_body_sizein nginx.conf - For Apache:
LimitRequestBodydirective
- For Nginx:
Notes
- The PHP limits (10M) are set higher than Laravel’s validation (5M) to ensure uploads succeed
- Always test in a staging environment before deploying to production
- Monitor your server’s performance after increasing these limits
Laravel Cloud (production)
RockyGlobal production deploys to Laravel Cloud (see.github/workflows/ci.yml). In that environment:
public/.htaccessphp_valuedirectives are not applied (no Apache mod_php).public/.user.inimay or may not be honored depending on the PHP-FPM pool; do not rely on it alone.- HTTP 413 on
PUT /events/config/basic_info/{id}/update-general-aspectis usually thrown by Laravel’s globalValidatePostSizemiddleware whenContent-Lengthexceeds PHPpost_max_size, beforeEventosController::updateGeneralAspectruns. The generic Symfony error page (“Oops! An Error Occurred”) is a symptom of that early rejection. - These upload rejections are not stored in MySQL (
failed_jobs,communication_logs, etc. will not show them).
How to confirm in Laravel Cloud logs
- Open the Laravel Cloud dashboard for the production environment.
- Go to Logs.
- Filter around the incident time for:
- Access logs:
update-general-aspectwith status413 - Application logs:
PostTooLargeExceptionorThe POST data is too large
- Access logs:
- Optional: use the Laravel Cloud logs API with an organization API token (
LARAVEL_CLOUD_API_TOKENlocally).
Application-side mitigations (implemented)
- Friendly redirect when
PostTooLargeExceptionis thrown (bootstrap/app.php). - Client-side checks in the event design form (5 MB per image, combined cap).
- If uploads still fail near 5–8 MB after deploy, open a Laravel Cloud support ticket to raise
post_max_size/ proxy body limits for the environment.
