Jump to content

Archived

This topic is now archived and is closed to further replies.

FredFredrickson

Create files as you download them?

Recommended Posts

I have a game I'm working on where you can store small bits of data up on a MySQL managed PHP server, and then go browse to the site via the net and see what other people have created. I want the users to be able to click on any of the items that have been uploaded (which are just stored as data in my MySQL database) and be able to download them in all together in a text file with a custom extension, which I want a download dialog box to appear for.

Since the content will constantly be changing, it seems silly to have the script actually generate files to download... but I'm not sure how I could have it pull the data together when the user clicks an item to download. Is there some way to 'trick' the browser into thinking it's supposed to be downloading a file when in actuality php is just building the data for it and passing it along as a file? I'm not sure if I can explain this clearly enough...! Hope someone understands! [img src=\"style_emoticons/[#EMO_DIR#]/unsure.gif\" style=\"vertical-align:middle\" emoid=\":unsure:\" border=\"0\" alt=\"unsure.gif\" /]

Share this post


Link to post
Share on other sites
this is just like sending an actual file to the browser through PHP for downloading, except that instead of reading the file itself out to the browser, you read the content.

have a look on google for "php header download" or "php download script"; there are even a few examples in the PHP manual (under header()) for sending automatic download cues to the browser. with some hacking together of the bits and pieces, you can create a downloading script like this (i did, except that i was sending actual files for download).

hope this helps.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.