Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
可能重复: PHP - 向用户发送文件
我编写了一个脚本,可以成功地将用户数据输出到我服务器上的 CSV 文件。
我的问题:有没有办法让 CSV 文件弹出以便用户可以打开它?照原样,打开文件的唯一方法是直接从服务器。
<?php $csv_file = '/path/to/yourfile.csv'; // path to the csv file you're generating on the server header('Content-type: text/csv'); header('Content-Disposition: attachment; filename="'.basename($csv_file)); readfile($csv_file); ?>