- 上傳時應檢查副檔名,最基本的檢查
- 上傳後應對檔名進行重新命名,而且加入亂數
- 對檔案存放所在的目錄,除去所有相關程式的執行權
- 檔案和主程式伺服器最後獨立,那就不怕存在偷 Script 情況,即 (File Server + Main Web Server)
- 不要隨意打開用戶所上傳的檔..(大魚!?)..
$_FILES[‘userfile’][‘type’]
The mime type of the file, if the browser provided this information. An example would be “image/gif”. This mime type is however not checked on the PHP side and therefore don’t take its value for granted.
mime_content_type (PHP 4 >= 4.3.0, PHP 5)
1 |
|
fileinfo (PHP >= 5.3.0, PECL fileinfo >= 0.1.0)
1 |
|
至於那種方法好,個人喜好
(任何事都是靠累積,這就是所謂既經驗, 前人種樹後人乘涼)