0

Possible Duplicate:
How to make PDF file downloadable in HTML link?
Download file from site PHP

I have a PHP web page that contains a fairly large table of data that is dynamically obtained from a database. Part of the job spec states that there needs to be a download link on the page. This download link will save the tabular data to a file, and will present the user with a save dialog box so that he can name the file. After the file is downloaded I want to page to still be visible in the browser window.

I've done this before, but I can't recall the details. I'm thinking about something like this pseudo-code, putting it in a separate file:

header('Content-disposition: attachment; filename=huge_document.pdf');
header('Content-type: application/pdf');
<while not finished>
display row of data
<end>

and then link to it like this:

  href="downloadfile.php?page=mypage">download file</a>

Apologies if this is already discussed on the site. I did not find a specific case that fit my requirements.

Community
  • 1
  • 1
Jack Albright
  • 509
  • 3
  • 11

0 Answers0