# How to Increase PHP POST Size for Resume Upload

## Problem
Getting "POST data is too large" error when uploading multiple resume files.

## Solution

### Method 1: Update php.ini file (Recommended)

1. **Find your php.ini file location:**
```bash
php --ini
# Or
php -i | grep php.ini
```

2. **Edit php.ini file:**
```bash
sudo nano /etc/php/8.2/fpm/php.ini
# Or for CLI
sudo nano /etc/php/8.2/cli/php.ini
```

3. **Update these settings:**
```ini
; Maximum size of POST data that PHP will accept
post_max_size = 200M

; Maximum size of an uploaded file
upload_max_filesize = 200M

; Maximum amount of memory a script may consume
memory_limit = 512M

; Maximum execution time of each script in seconds
max_execution_time = 600

; Maximum time in seconds a script is allowed to parse input data
max_input_time = 600

; Maximum number of files that can be uploaded via a single request
max_file_uploads = 50
```

4. **Restart PHP-FPM and Nginx:**
```bash
sudo systemctl restart php8.2-fpm
sudo systemctl restart nginx
```

### Method 2: Update via .htaccess (If using Apache)

Create or edit `.htaccess` in project root:
```apache
php_value upload_max_filesize 200M
php_value post_max_size 200M
php_value memory_limit 512M
php_value max_execution_time 600
php_value max_input_time 600
php_value max_file_uploads 50
```

### Method 3: Update Nginx Configuration (Additional)

Edit Nginx config:
```bash
sudo nano /etc/nginx/nginx.conf
```

Add/Update in `http` block:
```nginx
http {
    # Maximum client body size (for POST/upload)
    client_max_body_size 200M;
    
    # Timeouts
    client_body_timeout 600s;
    client_header_timeout 600s;
    send_timeout 600s;
    
    # Buffer sizes
    client_body_buffer_size 128k;
    client_header_buffer_size 4k;
    large_client_header_buffers 8 16k;
}
```

Restart Nginx:
```bash
sudo systemctl restart nginx
```

### Method 4: Runtime Configuration (Temporary - Not Recommended)

Add at the top of your PHP file:
```php
ini_set('post_max_size', '200M');
ini_set('upload_max_filesize', '200M');
ini_set('memory_limit', '512M');
ini_set('max_execution_time', '600');
ini_set('max_input_time', '600');
```

**Note:** This won't work for `post_max_size` and `upload_max_filesize` as they cannot be changed at runtime.

## Verify Changes

Create a test file `info.php`:
```php
<?php
phpinfo();
```

Access it via browser and search for:
- `post_max_size`
- `upload_max_filesize`
- `memory_limit`

## Current API Limits After Fix

Once PHP settings are updated, the API will support:
- **Max files per request:** 20 files
- **Max file size:** 10MB per file
- **Max total upload:** 100MB total
- **Timeout:** 10 minutes (600 seconds)

## Check Current Settings

Run this command to see current PHP limits:
```bash
php -i | grep -E "post_max_size|upload_max_filesize|memory_limit|max_execution_time|max_input_time"
```

## Troubleshooting

If still facing issues:

1. **Check both php.ini locations:**
```bash
# For PHP-FPM (web requests)
sudo nano /etc/php/8.2/fpm/php.ini

# For CLI (command line)
sudo nano /etc/php/8.2/cli/php.ini
```

2. **Check Nginx error logs:**
```bash
sudo tail -f /var/log/nginx/error.log
```

3. **Check PHP-FPM logs:**
```bash
sudo tail -f /var/log/php8.2-fpm.log
```

4. **Verify PHP-FPM is using correct php.ini:**
```bash
sudo systemctl status php8.2-fpm
```

## Recommended Settings for Production

```ini
post_max_size = 200M
upload_max_filesize = 200M
memory_limit = 512M
max_execution_time = 600
max_input_time = 600
max_file_uploads = 50
```

These settings will allow:
- Up to 20 files per request (API limit)
- Each file up to 10MB (API limit)
- Total upload up to 100MB (API limit)
- Processing time up to 10 minutes
