RedMist Posted October 2, 2008 Share Posted October 2, 2008 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) Quote Link to comment https://forums.phpfreaks.com/topic/126721-solved-downloading-a-csv-file-without-creating-one-on-server/ Share on other sites More sharing options...
redarrow Posted October 2, 2008 Share Posted October 2, 2008 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........ Quote Link to comment https://forums.phpfreaks.com/topic/126721-solved-downloading-a-csv-file-without-creating-one-on-server/#findComment-655448 Share on other sites More sharing options...
PFMaBiSmAd Posted October 2, 2008 Share Posted October 2, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/126721-solved-downloading-a-csv-file-without-creating-one-on-server/#findComment-655546 Share on other sites More sharing options...
RedMist Posted October 3, 2008 Author Share Posted October 3, 2008 Some good advice. I stored the data in a serialized session variable, and all is well. Thanks guys. Quote Link to comment https://forums.phpfreaks.com/topic/126721-solved-downloading-a-csv-file-without-creating-one-on-server/#findComment-656353 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.