且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

强制使用 PHP 下载文件

更新时间:2023-12-04 20:44:40

.htaccess 解决方案

要强制下载服务器上的所有 CSV 文件,请添加您的 .htaccess 文件:

.htaccess Solution

To brute force all CSV files on your server to download, add in your .htaccess file:

AddType application/octet-stream csv

PHP 解决方案

header('Content-Type: application/csv');
header('Content-Disposition: attachment; filename=example.csv');
header('Pragma: no-cache');
readfile("/path/to/yourfile.csv");