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

PHP file download example_PHP tutorial

WBOY
Release: 2016-07-20 11:10:03
Original
1131 people have browsed it

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...
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