Skip to content

Instantly share code, notes, and snippets.

@slav123
Created June 7, 2013 05:51
Show Gist options
  • Save slav123/5727287 to your computer and use it in GitHub Desktop.
Save slav123/5727287 to your computer and use it in GitHub Desktop.
export file stream in PHP
<?php
$fileName = 'somefile.csv';
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header('Content-Description: File Transfer');
header("Content-type: text/csv");
header("Content-Disposition: attachment; filename={$fileName}");
header("Expires: 0");
header("Pragma: public");
$fh = @fopen( 'php://output', 'w' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment