I wonder if it is possible to send text file which is just at this moment prepared and it would be best if the file coud be send without creating on disc.
For example I would like to have on my web

<a href="day.php">this day</a>

and when you click on this link day.php starts sending file day.txt which wil contain only one line with "monday" or "tuesday" etc. So browser will ask where you want to save this file. Is it possible to even send file day.txt without creating it on server?

Sorry for disturbing. I should better read the manual. It is just simple:

<?php
header('Content-type: application/txt');
header('Content-Disposition: attachment; filename="day.txt"');
echo date("l");
echo "\r\n";
?>

Hi!

You did not disturbed here.

It was very usefull for me and solved mine problem here.

Thanks,

Chess Patzer.

Sorry for disturbing. I should better read the manual. It is just simple:

<?php
header('Content-type: application/txt');
header('Content-Disposition: attachment; filename="day.txt"');
echo date("l");
echo "\r\n";
?>

Thanks buddy!

Sorry for disturbing. I should better read the manual. It is just simple:

<?php
header('Content-type: application/txt');
header('Content-Disposition: attachment; filename="day.txt"');
echo date("l");
echo "\r\n";
?>

There manual page on the readfile() function has some really good information and examples on sending a HTTP response with different headers. For example, if you want to support resuming downloads.

http://php.net/manual/en/function.readfile.php

A good thing to note for having PHP send your files is that you should use flush() if you want to start sending immediately. Otherwise PHP will buffer the output.
http://www.php.net/manual/en/function.flush.php

This is useful if you're sending a large txt download.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.