1

I am trying this simple code to download csv file via my web page but didn't work.

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

the error is "internet explorer can't find "csv_download.php" the file link on my web page

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

anything missing?

1
  • 1
    Your PHP file either has the wrong name or is in the wrong place Commented Sep 13, 2012 at 19:48

1 Answer 1

3

Your PHP file is not at the URL you expect. Always set the full path where possible:

<a href="/csv_download.php">...
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.