php通过网页下载csv文件

时间:2012-09-13 19:47:44

标签: php html

我正在尝试使用这个简单的代码通过我的网页下载csv文件但是没有用。

     <?PHP
      header('Content-Type: application/csv'); 
      header('Content-Disposition: attachment; filename=test.csv'); 
      header('Pragma: no-cache');
      echo readfile('test.csv'); 
      ?>

错误是“Internet Explorer找不到”csv_download.php“我网页上的文件链接

                 <a href="csv_download.php">Click here to download the "CSV" file</a>

什么遗失?

1 个答案:

答案 0 :(得分:2)

您的PHP文件不在您期望的URL中。始终尽可能设置完整路径:

<a href="/csv_download.php">...
相关问题