欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

PHP 下载txt文件 功能

程序员文章站 2022-06-02 09:14:41
...
$filename = $file; //文件路径
        $mime = 'application/force-download';
        header('Pragma: public');
        header('Expires: 0');
        header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
        header('Cache-Control: private',false);
        header('Content-Type: '.$mime);
        header('Content-Disposition: attachment; filename="'.basename($filename).'"');
        header('Content-Transfer-Encoding: binary');
        header('Connection: close');
        readfile($filename);
        exit();

以上就介绍了PHP 下载txt文件 功能,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。