Jump to content

[SOLVED] Downloading a CSV file, without creating one on server


Recommended Posts

After I display a table of data on my screen, I'd like to show a "Download CSV file" link.

 

Is there a way to do this, without going to a new page and outputing header, etc, and without creating a physical file on the server disk.

 

I'd like it to act as if there is a physical file on the server, so when you click, you get the download dialog box appear.

 

 

I don't want to refresh the same page, as the MySQL query is quite intensive, but I don't want to lose the data on screen when I download the CSV either.

 

(BTW, I'm ok generating CSV output, just the mechanics of downloading I need help with)

 

(BTW, H! - First Post - I'm Rob, PHP programmer of a few years, and willing to help)

sorry your need to force the download mate........

 

go here read.......

 

http://www.phpfreaks.com/forums/index.php/topic,95433.0.html

 

if you dont want a file sitting on the server to force the download then your

need to create a gd image and lay the screen info on it then download that.........

 

i dont understand why you can not create the info on a flat file and let them download it........

If you don't want to re-query the database if they choose to download the file, I recommend storing (cache) the necessary data in a session. If they do click on the download link, the download page (could be the same page that they are currently on) will produce the output from the data in the session. If they don't choose to download the file, the session will end when they close their browser and the session garbage collection will eventually delete the session data file on the server.

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.