| | |
Create and send text file
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Mar 2007
Posts: 2
Reputation:
Solved Threads: 0
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 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?
For example I would like to have on my web
PHP Syntax (Toggle Plain Text)
<a href="day.php">this day</a>
•
•
Join Date: Mar 2007
Posts: 2
Reputation:
Solved Threads: 0
Sorry for disturbing. I should better read the manual. It is just simple:
PHP Syntax (Toggle Plain Text)
<?php header('Content-type: application/txt'); header('Content-Disposition: attachment; filename="day.txt"'); echo date("l"); echo "\r\n"; ?>
•
•
Join Date: Aug 2008
Posts: 1
Reputation:
Solved Threads: 0
Hi!
You did not disturbed here.
It was very usefull for me and solved mine problem here.
Thanks,
Chess Patzer.
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 Syntax (Toggle Plain Text)
<?php header('Content-type: application/txt'); header('Content-Disposition: attachment; filename="day.txt"'); echo date("l"); echo "\r\n"; ?>
•
•
Join Date: Nov 2009
Posts: 1
Reputation:
Solved Threads: 0
Thanks buddy!
•
•
•
•
Sorry for disturbing. I should better read the manual. It is just simple:
PHP Syntax (Toggle Plain Text)
<?php header('Content-type: application/txt'); header('Content-Disposition: attachment; filename="day.txt"'); echo date("l"); echo "\r\n"; ?>
0
#5 Nov 11th, 2009
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.
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.
www.fijiwebdesign.com - web design and development and fun
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
![]() |
Similar Threads
- how do I send a text file to a printer connected to the client's computer (ASP.NET)
- Searching a text file (Python)
- How do you create a text file? (C)
- how do i read the last line of a text file? (Python)
- Having roblems using PHP to send info as text file (PHP)
- Create stats from a text file (Java)
Other Threads in the PHP Forum
- Previous Thread: how to write regular expression in PHP?
- Next Thread: DATA TYPE in phpmyadmin
Views: 6554 | Replies: 4
| Thread Tools | Search this Thread |
Tag cloud for PHP
.htaccess access ajax apache api array beginner binary broken cakephp checkbox class cms code cron curl database date datepart directory display download dynamic echo email error file files folder form forms function functions google head href htaccess html image include insert integration ip java javascript joomla jquery limit link list login loop mail menu methods mlm mod_rewrite multiple mysql oop parse password paypal pdf php problem query radio random recursion regex remote script search select seo server sessions sms soap source space speed sql structure syntax system table tutorial update updates upload url validation validator variable video web xml youtube






