Home > php教程 > php手册 > php文件下载实例

php文件下载实例

WBOY
Release: 2016-06-13 11:25:55
Original
1253 people have browsed it

php教程文件下载实例
这里主要是利用php fopen函数来实现读取文件一个个传送到客户本地,有需要朋友可以参考一下。      

        
        
        
        
        
    set_time_limit(24*60*60);
    if (!isset($_POST['submit'])) die ();
    $destination_folder = './down/';   // 文件夹保存下载文件。必须以斜杠结尾
    $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);
    }
?>

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