|
-
Sep 20th, 2004, 03:48 AM
#1
Thread Starter
Hyperactive Member
Report download
Hello!
I need to generate online reports from a mysql db. Now i want to have a option which will be...
to generate a report fro the db...and download it as a text file...how can this be achieved ? I need to download the file without creating it on the server. Means i do not want to first create a text file on server and then download it...i just want to starightly download it...!
Please help!
Thanks!
Tapan Bhanot,
CEO, Avis Software.
Website: www.avissoftware.com
-
Sep 20th, 2004, 06:52 AM
#2
Frenzied Member
AFAIK, you cannot do this. There must be a version of the file on the server that will be served to the browser. You cannot feed something like a buffer to the user.
The easiest thing would be just to create the file in text file. But each time the page is executed to download the file, have part of your script check for files older than some x time, and delete them. That way your server doesn't fill up and you don't have to write a special app to do this randomly.
-
Sep 20th, 2004, 06:57 AM
#3
Thread Starter
Hyperactive Member
Hi Ober!
You are wrong at this thing my friend. This is possible and just needs some header manipulation...! I created a script like this and now i forgot how i did it...lemme check it out...and i will post here if i find it...!
Thanks!
Tapan Bhanot,
CEO, Avis Software.
Website: www.avissoftware.com
-
Sep 20th, 2004, 07:12 AM
#4
Frenzied Member
Ok... no need to be a dick about it. If you already knew how to do it, you shouldn't be posting here in the first place.
-
Sep 20th, 2004, 07:15 AM
#5
Thread Starter
Hyperactive Member
hi
i jist forgot it...as i made that with help also...but now i don't even remember how i did it...that is why i posted it... 
thanks!
Tapan Bhanot,
CEO, Avis Software.
Website: www.avissoftware.com
-
Sep 20th, 2004, 07:26 AM
#6
You need to serve a few headers.
Content-type: text/plain
Content-disposition: attachment; report.txt
I think that's it. Then the output of your PHP script ought to be treated as a text file that gets downloaded.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Sep 20th, 2004, 07:28 AM
#7
Thread Starter
Hyperactive Member
Thanks! Do i have to do it like this:
header "Content-type: text/plain
Content-disposition: attachment; report.txt";
echo $somevar;
and this will get downloaded as text file right ?
Tapan Bhanot,
CEO, Avis Software.
Website: www.avissoftware.com
-
Sep 20th, 2004, 07:29 AM
#8
header('Content-type: text/plain');
header('Content-disposition: attachment; report.txt');
echo $content;
That should do it.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Sep 20th, 2004, 07:35 AM
#9
Thread Starter
Hyperactive Member
Tapan Bhanot,
CEO, Avis Software.
Website: www.avissoftware.com
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|