# Fix Upload Limits - "POST data is too large" Error

## Problem
When uploading banners or other files, you get the error: **"The POST data is too large"**

This happens because PHP's upload limits are too low.

## Current PHP Limits (Your System)
- `upload_max_filesize`: 2M (2 MB) ❌
- `post_max_size`: 8M (8 MB) ❌
- Banner validation allows: 10MB (updated)

## ✅ Solution 1: Update PHP.ini (Recommended for WAMP)

### Quick Fix Script
I've created a PowerShell script to automatically update your php.ini:

```powershell
# Run as Administrator
.\fix-upload-limits.ps1
```

### Manual Fix

**Step 1: Open php.ini**
1. Navigate to: `C:\wamp64\bin\php\php8.2.26\php.ini`
2. Open in a text editor (as Administrator)

**Step 2: Find and Update These Lines**
```ini
upload_max_filesize = 2M
post_max_size = 8M
max_execution_time = 30
max_input_time = 60
memory_limit = 128M
```

**Change to:**
```ini
upload_max_filesize = 10M
post_max_size = 12M
max_execution_time = 300
max_input_time = 300
memory_limit = 256M
```

**Step 3: Restart WAMP**
1. Click WAMP icon → Stop All Services
2. Click WAMP icon → Start All Services
3. Or restart your computer

**Step 4: Verify**
```bash
php -i | Select-String -Pattern "upload_max_filesize|post_max_size|memory_limit"
```

Expected output:
```
upload_max_filesize => 10M => 10M
post_max_size => 12M => 12M
memory_limit => 256M => 256M
```

## ✅ Solution 2: Using .htaccess (Already Applied)

I've updated `public/.htaccess` with upload limit settings. However, this only works if:
- Apache has `mod_php` enabled
- `.htaccess` files are allowed
- PHP is running as Apache module (not CGI/FastCGI)

**Note:** For WAMP, Solution 1 (php.ini) is more reliable.

## ✅ Solution 3: Temporary Workaround

If you can't change PHP settings immediately, I've updated the validation to allow up to 10MB, but you still need to increase PHP limits for it to work.

## Verification

After making changes, test the upload:
1. Go to `/admin/banners`
2. Try uploading a banner image
3. If it still fails, check Laravel logs:
   ```bash
   Get-Content storage\logs\laravel.log -Tail 20
   ```

## For Production

In production, update these in your server's `php.ini` or via hosting control panel:
- `upload_max_filesize = 10M`
- `post_max_size = 12M`
- `max_execution_time = 300`
- `memory_limit = 256M`

## Image Optimization Tips

To reduce file sizes:
- **Compress images**: Use tools like TinyPNG, ImageOptim
- **Resize images**: Recommended banner size is 1920x600px
- **Use WebP format**: Better compression than JPEG/PNG
- **Optimize before upload**: Don't upload raw camera photos

## Troubleshooting

### Still Getting Error After Changes?

1. **Verify php.ini was saved correctly**
   ```bash
   php --ini
   # Check the "Loaded Configuration File" path
   ```

2. **Check if WAMP restarted**
   - Make sure WAMP icon is green
   - Restart all services

3. **Check Apache error logs**
   - WAMP → Apache → Error logs

4. **Try clearing Laravel cache**
   ```bash
   php artisan config:clear
   php artisan cache:clear
   ```

5. **Check if .htaccess is being read**
   - Ensure `AllowOverride All` in Apache httpd.conf

## Quick Reference

**Current Limits (After Fix):**
- Upload: 10MB
- POST: 12MB
- Memory: 256MB
- Execution Time: 300 seconds

**Banner Validation:**
- Max size: 10MB
- Allowed types: jpeg, png, jpg, gif, webp
- Recommended dimensions: 1920x600px
