Created
September 9, 2013 10:34
-
-
Save arifmahmudrana/6493952 to your computer and use it in GitHub Desktop.
Create a file on the fly using php output buffering. Sometime we need to create file on the fly this serves the purpose.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* @source http://stackoverflow.com/questions/15769732/write-to-php-output-buffer-and-then-download-csv-from-buffer | |
*/ | |
$basic_info = fopen("php://output", 'w'); //Open output buffer to write | |
$content = file_get_contents(__FILE__); //Read the current file | |
fwrite($basic_info, $content); //Write to output buffer | |
fclose($basic_info); // Close the context | |
header("Content-disposition: attachment; filename=index.php"); | |
header("Content-Type: text/plain"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment