Jump to content

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\" /]
Link to comment
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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.