首页 > 技术文章 > php 下载

hssbsw 2013-11-06 21:24 原文

$file='url.xlsx';

        if (file_exists(EA_DIR_DATA . $file)) {
            header('Content-Description: File Transfer');
            header('Content-Type: application/octet-stream');
            header('Content-Disposition: attachment; filename='.basename($file));
            header('Content-Transfer-Encoding: binary');
            header('Expires: 0');
            header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
            header('Pragma: public');
            header('Content-Length: ' . filesize(EA_DIR_DATA .$file));
            ob_clean();
            flush();
            readfile(EA_DIR_DATA . $file);
        }

$file为要下载的文件,一般多文件都是压缩下载

推荐阅读