Jump to content

Avoiding overwriting temporary files.


cbh

Recommended Posts

My PHP application produces and displays a report in HTML. It also produces a text file version of the same report which will be used as the "Printable Version" if the user wants that.

 

The text version will always have the same name, say STAFF.TXT

 

My question is how do I avoid one user's STAFF.TXT of the file being overwritten by another user's STAFF.TXT ?

Link to comment
https://forums.phpfreaks.com/topic/43326-avoiding-overwriting-temporary-files/
Share on other sites

well you could add a counter to the end of the filename.  Such as STAFF1.txt,STAFF2.txt and increase the counter everytime you create a file.  Seems like you could end up with a large amount of txt files being created though.  I don't know how temporary these files are but a solution to this would be to store the file info in the database with a timestamp and delete any entries that are over a certain age. 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.