What is the correct syntax for this?
header('Content-Disposition: attachment; filename="{$_SESSION['name']} . '.txt');
This file works, albeit correctly, when the "view source" (HTML is not formatted, but contains the correct line breaks).
<?php header("Content-type: text/html"); session_start(); if(file_exists("chat") && filesize("chat") > 0){ $handle = fopen("chat", "r"); $contents = fread($handle, filesize("chat")); fclose($handle); ob_start(); $download = strip_tags($contents, '<br>'); $processed = preg_replace('#<br\s*/?>#i', "\n", $download); echo $processed; $var = ob_get_clean(); echo $var; } ?>
The variable $_SESSION['name'] has the value guest_158512 , and if you are viewing the source of the page I'm trying to save, it has all line breaks. How to save the current page as guest_158512.txt with the appropriate syntax?
source share