Home > php教程 > php手册 > body text

简单的PHP web文件分享

WBOY
Release: 2016-06-21 08:49:25
Original
780 people have browsed it

很简单,用于文件在web分享
1 执行*nix命令获取本目录文件
2 生成下载链接
3 支持中文名,名称内可含有空格
4 源代码请保存为utf-8编码
5 假设分享路径为http://xx_host/xx_dir,代码命名为index.php放在xx_dir目录,生成除index.php外的所有文件下载链接

 



<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>private file box</title>



<h2>private file box</h2>
<?php function list_file_url() {
	exec ( "/bin/ls", $res, $rc );
	//echo "<pre class="brush:php;toolbar:false">";
	// var_dump ( $res );
	// var_dump ( $rc );
	// echo "
Copy after login
"; if (0 == $rc) { //echo count ( $res ) . "
"; //echo "
"; for($i = 0; $i "; $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 "$encoded_filename"; echo "
"; echo "
"; } } } } list_file_url (); ?>



Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!