我的服务器上有一个CSV文件。如果用户点击了本应下载的链接,但它却在我的浏览器窗口中打开。
我的代码如下所示
<a href="files/csv/example/example.csv">
Click here to download an example of the "CSV" file
</a>
这是一个普通的work服务器,我所有的开发工作都在它上面。
我试过这样的方法:
<a href="files/csv/example/csv.php">
Click here to download an example of the "CSV" file
</a>
现在我的csv.php
文件的内容如下:
header('Content-Type: application/csv');
header('Content-Disposition: attachment; filename=example.csv');
header('Pragma: no-cache');
现在我的问题是它正在下载,但不是我的CSV文件。它会创建一个新文件。
https://stackoverflow.com/questions/1465573
复制相似问题