$text_to_write = 'Example text to be written to file';
$fwrt = fopen($path.'file.txt', 'w');
fwrite($fwrt,$text_to_write);
fclose($fwrt);
header('Content-type: text/plain');
header('Content-Disposition: attachment; filename="example.txt"');
readfile($path.'file.txt');
exit(); // if this line is not included entire page code will also be written into the file
Wednesday, January 16, 2013
Writing to downloadable file in PHP
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment