无量小猪

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

其实就是将你的的文件,通过二进制的方法,转成流文件让浏览器识别,或者替换头部信息的方式

    function downFileFromServer($showFileName, $downFilePath)    {        if(file_exists($downFilePath))        {            if(is_readable($downFilePath))            {                if(Trim($showFileName) == '')                {                 $showFileName = 'undefined';                }                ob_start();                ob_clean();                $file_size = filesize($downFilePath);                header('Content-Encoding:none');                header('Cache-Control:private');                header('Content-Length:' . $file_size);                header('Content-Disposition:attachment; filename=' . $showFileName);                header('Content-Type:application/octet-stream');                readfile($downFilePath);                ob_flush();            }        }    }    //Sample     downFileFromServer($fileurl, 真实文件地址);

posted on 2011-03-01 11:08  无量小猪  阅读(220)  评论(0编辑  收藏  举报