Expand|Select|Wrap|Line Numbers
- <?php
- $file = 'monkey.gif';
- if (file_exists($file)) {
- header('Content-Description: File Transfer');
- header('Content-Type: application/octet-stream');
- header('Content-Disposition: attachment; filename='.basename($file));
- header('Expires: 0');
- header('Cache-Control: must-revalidate');
- header('Pragma: public');
- header('Content-Length: ' . filesize($file));
- readfile($file);
- exit;
- }
- ?>
If I have the data stored in memory, can I generate the download file directly from that data? Or must I first write some temp file on the server so I can output the text file for download?
I have code for the 2nd option here, just wondering if option 1 is possible, if so do you have some sample code to demonstrate?