常見缺陷

MAX_FILE_SIZE 設(shè)置的值,不能大于 php.ini 文件 設(shè)置中 upload_max_filesize 選項設(shè)置的值。其默認值為 2M 字節(jié)。

如果內(nèi)存限制設(shè)置被激活,可能需要將 memory_limit 設(shè)置的更大些,請確認 memory_limit 的設(shè)置足夠的大。

如果 max_execution_time 設(shè)置的值太小,腳本運行的時間可能會超過該設(shè)置。因此,也請保證 max_execution_time 足夠的大。

注意: max_execution_time 僅僅只影響腳本本身運行的時間。任何其它花費在腳本運行之外的時間,諸如用函數(shù) system() 對系統(tǒng)的調(diào)用、sleep() 函數(shù)的使用、數(shù)據(jù)庫查詢、文件上傳等,在計算腳本運行的最大時間時都不包括在內(nèi)。

警告

max_input_time 以秒為單位設(shè)定了腳本接收輸入的最大時間,包括文件上傳。對于較大或多個文件,或者用戶的網(wǎng)速較慢時,可能會超過默認的 60 秒。

如果 post_max_size 設(shè)置的值太小,則較大的文件會無法被上傳。因此,請保證 post_max_size 的值足夠的大。

As of PHP 5.2.12, the max_file_uploads configuration setting controls the maximum number of files that can uploaded in one request. If more files are uploaded than the limit, then $_FILES will stop processing files once the limit is reached. For example, if max_file_uploads is set to 10, then $_FILES will never contain more than 10 items.

不對正在操作的文件進行驗證可能意味著用戶能夠訪問其它目錄下的敏感信息。

請注意 CERN httpd 似乎會丟棄它從客戶端獲得的 content-type mime 頭信息中第一個空格后所有的內(nèi)容,基于這一點,CERN httpd 不支持文件上傳特性。

鑒于文件路徑的表示方法有很多種,我們無法確保用使用各種外語的文件名(尤其是包含空格的)能夠被正確的處理。

開發(fā)人員不應(yīng)將普通的 input 輸入字段和文件上傳的字段混用同一個表單變量(例如 input 名都用 foo[])。