PHP 要上傳檔案,遇到檔案太大(預設上限2M),php.ini 要修改哪些地方才能夠解決這個問題呢?
PHP 檔案上傳 遇到 容量太大 要修改 php.ini 的參數
PHP 遇到檔案太大的上限,要修改 php.ini 才能完成(或者 .htaccess),要修改下面兩個參數: (以下為預設值)
- upload_max_filesize = 2M
- post_max_size = 8M
於 /etc/php/*/apache2/php.ini
找到這兩個參數,修改成需要的大小即可,下述以 40M 為範例
; Maximum allowed size for uploaded files.
; http://php.net/upload-max-filesize
upload_max_filesize = 40M; Maximum size of POST data that PHP will accept.
; Its value may be 0 to disable the limit. It is ignored if POST data reading
; is disabled through enable_post_data_reading. ; http://php.net/post-max-size
post_max_size = 42M
於 .htaccess 的設定
php_value upload_max_filesize 40M
php_value post_max_size 42M