Karaethon Posted August 12, 2019 Share Posted August 12, 2019 I have, on my site, a server output page (after the user has completed certain steps the server generates data to display for the user). For security purposes the server cannot retrieve this data after the page is left, it is gone for good (unless the transaction ID from paypal is supplied), so I want to make a button that dumps the data to a text file the user can then save or print. While the page is active I could retrieve the data from the server again, so... can javascript do this on client side (if so please give me an example of how) or should I just requery the server and get it to create the text file and then send it to the user? Quote Link to comment https://forums.phpfreaks.com/topic/309087-creating-text-file-for-user/ Share on other sites More sharing options...
Barand Posted August 12, 2019 Share Posted August 12, 2019 You could use output buffering when generating the page. Save the buffered content to a uniquely named file then output to the screen. Provide a download link to the file. Quote Link to comment https://forums.phpfreaks.com/topic/309087-creating-text-file-for-user/#findComment-1568967 Share on other sites More sharing options...
requinix Posted August 12, 2019 Share Posted August 12, 2019 The downside to files, like actual files on the server, is that they need to be cleaned up after a while. If generating the text isn't particularly problematic then I would do it from scratch every time it's needed - be that the first display or an additional download. Quote Link to comment https://forums.phpfreaks.com/topic/309087-creating-text-file-for-user/#findComment-1568969 Share on other sites More sharing options...
Karaethon Posted August 12, 2019 Author Share Posted August 12, 2019 1 hour ago, requinix said: The downside to files, like actual files on the server, is that they need to be cleaned up after a while. If generating the text isn't particularly problematic then I would do it from scratch every time it's needed - be that the first display or an additional download. Yeah, that's why I want to generate the file only if the user clicks save. 1 hour ago, Barand said: You could use output buffering when generating the page. Save the buffered content to a uniquely named file then output to the screen. Provide a download link to the file. Hmm, IDK if I can do this, the final output isn't ever on the server, the user javascript posts to the different php files the server and assembles the final output on user side. I found this idk if it will do what I need, but I'll play with it. Quote Link to comment https://forums.phpfreaks.com/topic/309087-creating-text-file-for-user/#findComment-1568976 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.