PHP fastcgi模式上傳大檔案(大約有300多K)報錯_php技巧

來源:互聯網
上載者:User

最近在項目中中上傳圖片時,大約有300多K,結果報了個伺服器錯誤,以前從未遇到過,錯誤的內容如下:

mod_fcgid: HTTP request length 132296 (so far) exceeds MaxRequestLen (131072)

查了下資料,發現fastcgi預設的請求大小為131072,於是在apache配置中添加了MaxRequestLen 配置就好了。如果你只需要修改單個虛擬機器主機的 MaxRequestLen,原來是fastcgi模式下的設定問題,需要在設定檔.htaccess或者直接在apache的設定檔http.conf 中指明,如下:

代碼如下

複製代碼 代碼如下:

<IfModule mod_fcgid.c>
AddHandle fcgid-script .fcgi
FcgidConnectTimeout 20
# to get around upload errors when uploading images increase the MaxRequestLen size to 15MB
FcgidMaxRequestLen 15728640
</IfModule>

如果你是php+apache windows環境下的話我們如下配置即可

在php.ini中找到

upload_max_filesize,及其他post_max_size、max_input_time、memory_limit、 max_execution_time配置

把上傳大小修改之後重啟apache 即可解決

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.