1

I am trying to generate an HTML file with PHP and Force the Browser to Download it. The Problem is, even if i Generate a file with an unknown extension e.g. ".mail" the file is shown in the Browser Window. I tried to rewrite the HTTP Headers, but it seems that the Server (PLESK) is ignoring them: Here is my PHP Code:

<?php 
header('Content-Description: File Transfer');
header('Content-Disposition: attachment; filename="mail.html"');
header("Pragma: public");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
//print_r($_POST);
switch ($_POST['radios']){
    case 1:

        include("1.include");

        print($_POST["editor1"]);

        include("1-foot.include");
        brake;
    case 2:
        brake;
    case 3:
        brake;
    case 4:
        brake;
}

?>

Firebug is showing me this Headers:

Connection  
Keep-Alive
Content-Type    
text/html
Date    
Fri, 23 Oct 2015 22:06:41 GMT
Keep-Alive  
timeout=5, max=100
Server  
Apache
Transfer-Encoding   
chunked
X-Powered-By    
PleskLin
Quelltext anzeigen
Accept  
text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Encoding 
gzip, deflate
Accept-Language 
de,en-US;q=0.7,en;q=0.3
Cache-Control   
no-cache
Connection  
keep-alive
Cookie  
_pk_id.1.974f=82b4d2cf248e9b40.1420714194.2.1421423646.1420714194.; __atuvc=1%7C1%2C1%7C2
Host    
**********************
Pragma  
no-cache
Referer 
**********************
User-Agent  
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:41.0) Gecko/20100101 Firefox/41.0

1 Answers1

2

Got it :) There was 1 Space before the <?php> which caused the headers to not being sent :) Thanks