關於 PHP, Linux, Open Source 及個人生活記載的網誌。
RSS icon
  • Apache 限制上傳檔案體積

    Posted on April 26th, 2008 Sam Tang No comments

    在 Apache 裡面有一個選項是 LimitRequestBody,這個選項可以限制用戶送出的 HTTP 請求內容。這個選項可以在 .htaccess 或 httpd.conf 裡使用,而如果在 httpd.conf 內使用,分別可以用在 virtualhost 或目錄屬性設定。而 LimitRequestBody 的設定值是介乎 0 (無限制) 至 2147483647 (2GB)。

    例如要在目錄 /home/httpd/html/www.mydomain.com/uploads 設定上傳限制為 100K,可以在 .htaccess 或 httpd.conf 加入以下語句:

    <Directory "/home/httpd/html/www.mydomain.com/uploads">
       LimitRequestBody 102400
    </Directory>

    如果透過 .htaccess 設定,儲存檔案後會立即生效;如透過 httpd.conf 設定,須要重新啟動 Apache。


    Leave a reply

    *
    To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
    Click to hear an audio file of the anti-spam word