首页 > php框架 > php文件下载实例

php文件下载实例

php文件下载实例

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

<form method="post">         
<input name="url" size="20" />         
<input name="submit" type="submit" />         
<!-- <input type="hidden" name="MAX_FILE_SIZE" value="2097152" />-->         
</form>         
<?php
    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);
    }
?>


本文地址:http://www.phprm.com/frame/php1005222.html

转载随意,但请附上文章地址:-)

标签:none

发表留言