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;
    
    }
原文地址:https://www.cnblogs.com/jxkshu/p/5253618.html