Jump to content


Photo

Create files as you download them?


  • Please log in to reply
2 replies to this topic

#1 FredFredrickson

FredFredrickson
  • Members
  • Pip
  • Newbie
  • 2 posts

Posted 06 June 2006 - 04:58 AM

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\" /]

#2 akitchin

akitchin
  • Staff Alumni
  • Advanced Member
  • 2,516 posts
  • LocationCalgary, AB, Canada

Posted 06 June 2006 - 05:07 AM

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.

#3 FredFredrickson

FredFredrickson
  • Members
  • Pip
  • Newbie
  • 2 posts

Posted 06 June 2006 - 05:11 AM

Thanks a lot, I'll give it a look!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users