php 下载图片 文件

$file = dirname(dirname(__FILE__)) . $_GET['download'];            //获取图片的绝对路径
header("Content-type: octet/stream");                                         //下载的文件类型   这里是任何文件
header("Content-disposition:attachment;filename=".$file.";");
header("Content-Length:".filesize($file));
readfile($file);
exit;

 

protected function mk_csv($fileUrl) {

    
        header('Content-Type: application/octet-stream');
        header('Content-Disposition: attachment; filename=' . $fileUrl.';');
        header('Content-Transfer-Encoding: binary');
        header('Content-Length: ' . filesize($fileUrl));
        readfile($fileUrl);
        exit;
    
    }

 

posted @ 2016-03-08 12:37  IT树  阅读(579)  评论(0编辑  收藏  举报