2014-01-27 36 views

回答

0

通常通過在$DOCUMENT_ROOT/rsrc.php處放置一個PHP文件,然後用/鍵入URL並輸入一些額外的東西。

rsrc.php負責確定如何處理URL中的數據(可從$_SERVER中提取)。

0

我會做的方式是讓一個.htaccess的規則,讓「rsrc.php」後重寫任何$ _GET如$ _GET [「load_file_relative_path」]

那我就做了一個名爲「腳本rsrc.php',然後檢查文件路徑是否有效,以及是否輸出內容(基本示例)。

<?php 
    $base_path = "" // set a bath path to prepend to the relative path 

    if(isset($_GET['load_file_relative_path'])) 
    { 
     // Check if file exists (put additional security checks here) 
     if(is_file($base_path . DIRECTORY_SEPARATOR . $_GET['load_file_relative_path'])) 
     { 

     // Depending on your use, hard-code header or get the mime type from file 
     header('Content-type: image/png'); 
     file_get_contents($base_path . DIRECTORY_SEPARATOR . $_GET['load_file_relative_path']) 
     exit(); 

     } 


    } 

?> 

當然,這是一個安全漏洞,所以你需要在地方檢查所必要的,因此只能從某些目錄載入圖像。