很簡單,用於文件在web分享
1 執行*nix命令獲取本目錄文件
2 生成下載鏈接
3 支持中文名,名稱內可含有空格
4 源代碼請保存為utf-8編碼
5 假設分享路徑為http://xx_host/xx_dir,代碼命名為index.php放在xx_dir目錄,生成除index.php外的所有文件下載鏈接
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>private file box</title> </head> <body> <h2>private file box</h2> <?php function list_file_url() { exec ( "tyncar.com/bin/ls", $res, $rc ); //echo "<pre>"; // var_dump ( $res ); // var_dump ( $rc ); // echo "</pre>"; if (0 == $rc) { //echo count ( $res ) . "<br />"; //echo "<br />"; for($i = 0; $i < count ( $res ); $i ++) { if ($res[$i] != "index.php") { //echo $res [$i] . "<br />"; $encoded_url = urlencode($res[$i]); $encoded_url = str_replace("+","%20",$encoded_url); $encoded_filename = iconv("GBK","UTF-8",$res[$i]); $encoded_temp_filename = explode(".",$encoded_filename); $encoded_filename = $encoded_temp_filename[0]; echo "<a href="./$encoded_url">$encoded_filename</a>"; echo "<br />"; echo "<br />"; } } } } list_file_url (); ?> </body> </html>