如何調整 php 應用的上傳附件大小?

來源:互聯網
上載者:User

最近搭建了 php 的 web 端郵件應用程式—— RoundCude(後續簡稱為: RC) 。

中間有檔案上傳的需求,因 RC 是 Php 寫的,上傳檔案的大小主要通過 php 控制。

控制 php 的容許上傳大小也有多種方式,一種全域控制 php.ini 檔案,二是通過 .htaccess 檔案控制

一、全域控制 php.ini 檔案
1、開啟檔案上傳
file_uploads = On

2、記憶體大小
memory_limit = 128M // 在被取消之前,一個指令碼可使用多少記憶體(位元組)

3、增加 post 方式提交的資料大小
post_max_size = 32M

4、允許上傳的最大上傳檔案大小
upload_max_filesize = 30M

5、最大的輸入時間。一個指令碼等待輸入資料的時間有多長(秒)
max_input_time = 60

6、增加進程執行的時間。一個指令碼可使用多少 CPU 秒
max_execution_time = 300

從邏輯順序上:memory_limit > post_max_size > upload_max_filesize,再加上一個前提 max_execution_time許可時間足夠長。

二、在 .htaccess 中添加上述對應的設定值
php_value upload_max_filesize 30M
php_value post_max_size 35M
php_value max_execution_time 300 

三、參考檔案
1、http://lists.roundcube.net/pipermail/users/2011-March/007748.html
2、http://www.radinks.com/upload/config.php

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.