Download csv from php
Moderator: General Moderators
Download csv from php
Hello. I have a website done in php. I want to have a hyperlink that when the user clicks on it will download a csv file that would be created in that moment. I've looked in different forums and in the php manual but havent been able to do it. Can somebody help? Thanks!
Re: Download csv from php
Code: Select all
<a href="download.php">Download</a>Code: Select all
<?php // download.php
header("Content-Type: text/csv");
header("Content-Disposition: attachment; filename=filename.csv"); // change the filename
// output your CSV content here
?>Re: Download csv from php
Thanks! Now, how should I output the csv. I just know that it has to be separated by |