-4

Possible Duplicate:
PHP - send file to user

I have written a script that successfully outputs userdata to a CSV file on my server.

My question: is there a way to make the CSV file popup so the user can open it? As is, the only way to open the file is directly from the server.

Community
  • 1
  • 1
stevenpepe
  • 267
  • 4
  • 16

1 Answers1

2
<?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);
?>
Nadh
  • 6,987
  • 2
  • 21
  • 21