I have a string which contains csv data. Can I somehow offer that string for download as a csv file without saving it before?
Thanks
I have a string which contains csv data. Can I somehow offer that string for download as a csv file without saving it before?
Thanks
<?php
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=\"my-data.csv\"");
$data="col1, col start and end col2,col3, \n";
$data .= "second line data";
echo $data;
?>
Above code will display a window in visitor browser asking to save file in local computer or open by suitable application.
header("Content-Disposition", "attachment;filename=myfilename.csv");