Jump to content

Creating text file for user


Karaethon

Recommended Posts

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

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.