PHP 上傳檔案隱藏路徑,做過檔案上傳安全性的進來看看哦

來源:互聯網
上載者:User
PHP 下載檔案隱藏路徑,做過檔案下載安全性的進來看看哦!
最近在弄檔案資源管理,在下載時隱藏檔案路徑採用的方案僅僅是,對存放檔案的目錄用apache配置使之無法直接存取目錄列表,rewrite技術可隱藏伺服器的目錄!
比如下載路徑本來為:http://miresearch.cn/uploadfile/resource/2012-05/8F4F5A42-1B4C-8B80-0EFC-9FF2346373BF.rar
如果不做出來,直接存取http://miresearch.cn/uploadfile/resource/2012-05這個可以查看伺服器此目錄下的所有檔案,後來經過了apache配置使http://miresearch.cn/2012-05/8F4F5A42-1B4C-8B80-0EFC-9FF2346373BF.rar可以實現下載檔案以隱藏伺服器目錄,且http://miresearch.cn/2012-05此目錄不能直接存取。

初學者對檔案下載僅僅做了這麼點工作,請各位高手看看,有什麼好建議方案,給小弟指導下~有做過檔案下載的安全性請過來看看,指引下哦~

------解決方案--------------------
帳號密碼驗證後直接輸出檔案...

例如

PHP code
header('Content-Type: application/octet-stream');$filesize = filesize('s.png'); //獲得檔案大小header('Last-Modified: '.gmdate('D, d M Y H:i:s') . ' GMT');header('Cache-Control: no-store, no-cache, must-revalidate');header('Cache-Control: pre-check=0, post-check=0, max-age=0');header('Content-Transfer-Encoding: binary');header('Content-Encoding: none');header('Content-type: application/force-download');header('Content-length: '.$filesize);header('Content-Disposition: attachment; filename="s.png"');readfile('s.png'); 
  • 聯繫我們

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