Generování souboru bez uložení na disk

Nacházíte se: / Programování / PHP

Ukázka kódu:

 $obsah = "Hello world!";
 $jmeno = "hello.txt";
 
 header( "Content-disposition: attachment; filename=" . $jmeno );
 header( "Content-Type: application/force-download" );
 header( "Content-Transfer-Encoding: binary" );
 header( "Content-Length: " . strlen( $obsah ) );
 header( "Pragma: no-cache" );
 header( "Expires: 0" );
 
 echo $obsah;
?>