Home  >  Article  >  Backend Development  >  PHP file download example_PHP tutorial

PHP file download example_PHP tutorial

WBOY
WBOYOriginal
2016-07-20 11:10:031073browse

php tutorial file download example
Here we mainly use the php fopen function to read files and transfer them to the client one by one. Friends can refer to it if necessary.



                                                                       " ?php
set_time_limit(24*60*60);
if (!isset($_POST['submit'])) die ();
$destination_folder = './down/'; // Folder to save downloaded files. Must end with a slash
$url = $_POST['url'];
$newfname = $destination_folder.basename($url);
$file = fopen($url, "rb");
if ($file) {
$newf = fopen($newfname, "wb");
if ($newf) while (!feof($file)) {
fwrite($newf , fread($file, 1024*8), 1024*8);
}
}
if ($file) {
fclose($file);
}
if ($newf) {
fclose($newf);
}
?>




http://www.bkjia.com/PHPjc/444753.html

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/444753.htmlTechArticlephp tutorial file download example. Here we mainly use the php fopen function to read files and transfer them to the client one by one. Friends can refer to it if necessary. form method=post input na...
Statement:
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