requireAuth(); header('Content-Type: application/json'); $result = [ 'success' => false, 'size' => 0, 'error' => 'No file uploaded', 'php_info' => [ 'upload_max_filesize' => ini_get('upload_max_filesize'), 'post_max_size' => ini_get('post_max_size'), 'memory_limit' => ini_get('memory_limit') ], 'server_info' => [ 'content_length' => $_SERVER['CONTENT_LENGTH'] ?? 0, 'content_type' => $_SERVER['CONTENT_TYPE'] ?? 'unknown' ] ]; if (isset($_FILES['test_file'])) { $file = $_FILES['test_file']; $result['size'] = $file['size']; $result['original_name'] = $file['name']; $result['type'] = $file['type']; $result['error_code'] = $file['error']; if ($file['error'] === UPLOAD_ERR_OK) { $result['success'] = true; $result['message'] = 'Upload successful'; } else { $result['error'] = getUploadErrorMessage($file['error']); } } echo json_encode($result); exit; } // Start session for main page if (session_status() === PHP_SESSION_NONE) { session_start(); } require_once '../includes/config.php'; require_once '../includes/database.php'; require_once '../includes/auth.php'; // Require authentication $auth = new Auth(); $auth->requireAuth(); ?> Upload Diagnostics

Upload Diagnostics Tool

PHP Upload Configuration

['current' => ini_get('upload_max_filesize'), 'recommended' => '20M', 'description' => 'Maximum file upload size'], 'post_max_size' => ['current' => ini_get('post_max_size'), 'recommended' => '25M', 'description' => 'Maximum POST request size'], 'memory_limit' => ['current' => ini_get('memory_limit'), 'recommended' => '256M', 'description' => 'Memory limit for PHP'], 'max_execution_time' => ['current' => ini_get('max_execution_time'), 'recommended' => '300', 'description' => 'Maximum execution time (seconds)'], 'max_input_time' => ['current' => ini_get('max_input_time'), 'recommended' => '300', 'description' => 'Maximum input time (seconds)'], 'file_uploads' => ['current' => ini_get('file_uploads'), 'recommended' => 'On', 'description' => 'File uploads enabled'], 'max_file_uploads' => ['current' => ini_get('max_file_uploads'), 'recommended' => '20', 'description' => 'Maximum simultaneous file uploads'] ]; foreach ($settings as $key => $setting) { $current = $setting['current']; $recommended = $setting['recommended']; $status = 'success'; $statusClass = 'success'; if ($key === 'file_uploads') { if ($current !== '1' && strtolower($current) !== 'on') { $status = 'ERROR - File uploads disabled!'; $statusClass = 'error'; } } elseif ($key === 'upload_max_filesize') { $currentBytes = return_bytes($current); $recommendedBytes = return_bytes($recommended); if ($currentBytes < $recommendedBytes) { $status = 'WARNING - Too small'; $statusClass = 'warning'; } } elseif ($key === 'post_max_size') { $currentBytes = return_bytes($current); $recommendedBytes = return_bytes($recommended); if ($currentBytes < $recommendedBytes) { $status = 'WARNING - Should be larger than upload_max_filesize'; $statusClass = 'warning'; } } echo ""; } ?>
SettingCurrent ValueRecommendedStatus
{$key} {$current} {$recommended} {$status}

Server Information

ItemValue
PHP Version
Web Server
Server API
Document Root
Max Request Size (calculated) bytes

Upload Test

Test different file sizes to identify the exact limit:

Nginx Configuration Check

Important: The error "client intended to send too large body" indicates an nginx limit.

Check these nginx settings in your server configuration:

Typical nginx configuration needed:

server {
    listen 80;
    server_name samuli.valavuo.net;
    root /path/to/website;
    index index.php;
    
    # Increase upload limits
    client_max_body_size 25M;
    client_body_buffer_size 128k;
    client_body_timeout 60s;
    
    location ~ \.php$ {
        fastcgi_pass unix:/var/run/php/php-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }
}

Next Steps

  1. If nginx is the issue: Update your nginx configuration with client_max_body_size 25M; and restart nginx
  2. If PHP is the issue: The .htaccess file should help, but you may need to update php.ini directly
  3. Test again: After making changes, test with the buttons above