[英]Why is PHP not allowing me to upload more than 2MB file?
我無法在我的網站表單中上傳超過 2MB 的圖片。
我已經在/etc/php/7.4/fpm/php.ini
中設置了所需的設置:
; 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 = 100M
.
.
;;;;;;;;;;;;;;;;
; File Uploads ;
;;;;;;;;;;;;;;;;
; Whether to allow HTTP file uploads.
; http://php.net/file-uploads
file_uploads = ON
; Temporary directory for HTTP uploaded files (will use system default if not
; specified).
; http://php.net/upload-tmp-dir
;upload_tmp_dir =
; Maximum allowed size for uploaded files.
; http://php.net/upload-max-filesize
upload_max_filesize = 100M
; Maximum number of files that can be uploaded via a single request
max_file_uploads = 20
.
.
; Maximum amount of memory a script may consume
; http://php.net/memory-limit
memory_limit = 128M
但問題是,當我在索引頁中打印 php 信息時,我得到了不同的 output:/
為什么會發生這種情況,我該如何解決?
兩個 PHP 配置選項控制最大上傳大小: upload_max_filesize
和post_max_size
。 如果您要顯着增加這些值,請考慮同時增加max_input_time
和max_execution_time
值
如果您在 php.ini 中找不到 2mb 設置的來源,您可以在 .htaccess 文件中覆蓋
php_value upload_max_filesize 10M
php_value post_max_size 10M
php_value max_input_time 300
php_value max_execution_time 300
或者如果需要,直接在您的 PHP 頁面中
<?php
ini_set('upload_max_filesize', '10M');
ini_set('post_max_size', '10M');
ini_set('max_input_time', 300);
ini_set('max_execution_time', 300);
?>
例如...
如果 Upper answers 未修復,請嘗試以下步驟:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.