Home > Backend Development > PHP Tutorial > Simple PHP for web files_PHP tutorial

Simple PHP for web files_PHP tutorial

WBOY
Release: 2016-07-21 14:53:28
Original
898 people have browsed it

Very simple, used for file sharing on the web

1 Execute *nix command to obtain the files in this directory
2 Generate download link
3 Supports Chinese names, and the name can contain spaces
4 Please save the source code as utf-8 encoding
5 Assume that the sharing path is http://xx_host/xx_dir, the code is named index.php and placed in the xx_dir directory, and all file download links except index.php are generated

<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 class="brush:php;toolbar:false">";
	// var_dump ( $res );
	// var_dump ( $rc );
	// echo "
"; if (0 == $rc) { //echo count ( $res ) . "
"; //echo "
"; for($i = 0; $i < count ( $res ); $i ++) { if ($res[$i] != "index.php") { //echo $res [$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 (); ?>
Copy after login

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/371393.htmlTechArticle is very simple. It is used to share files on the web. 1. Execute the *nix command to obtain files in this directory. 2. Generate download links. 3. Support Chinese name, the name can contain spaces 4 Please save the source code as utf-8 encoding 5 Hypothetical points...
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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template