預設 PHP 安裝限制上傳 2MB(`upload_max_filesize`),實際常遇 8MB 瓶頸(`post_max_size` 預設 8MB)。本文提供系統排查清單、配置修改指南與現代分片上傳架構建議。
| 配置項 | 預設值 | 建議值(100MB 例) | 層級 |
|---|---|---|---|
| upload_max_filesize | 2M | 100M | PHP |
| post_max_size | 8M | 110M (> upload_max_filesize) | PHP |
| memory_limit | 128M | 256M | PHP |
| max_execution_time | 30 | 300 (秒) | PHP |
| max_input_time | 60 | 300 | PHP |
| client_max_body_size | 1m | 100m | Nginx |
systemctl reload php-fpm 或 service php7.4-fpm reload。nginx -t && nginx -s reload。post_max_size (8M) < 上傳檔案 → PHP 直接丟棄 `$_POST` 和 `$_FILES`,`$_FILES` 為空陣列。參考《PHP 大檔案上傳配置全攻略》分片架構。核心優勢:
修改 `upload_max_filesize`、`post_max_size`、`memory_limit`、`max_execution_time`、`client_max_body_size` 五大參數並重載服務,可解決 8MB 瓶頸。**但單請求上傳大檔案本質脆弱**,生產環境強烈建議遷移至**分片上傳架構**(Uppy/WebUploader + 後端合併 API),一次性解決大小、超時、斷點、進度、秒傳所有痛點。