Page 1 of 1

[SOLVED] programatically creating a temporary file

Posted: Fri Jan 07, 2005 9:03 am
by waskelton4
Hello group,

I am needing to grab data from a database and create a file temporarlily for use with the exec() function. Is there any easy way to do this without actualy going through all of the steps of fopen() fwrite()... then deleting the file when i'm done.

Does such a function exists that I may be able to send some text to it and a filename and use it until the page changes and have it deleted?

hope that made sense..:)

thanks to all

Will

Posted: Fri Jan 07, 2005 5:53 pm
by feyd
you can make a function that does the filename and text things.. You'd need to set a handler for shutdown or some other events to handle the page ending.. (it's better to delete it when you are actually finished with it)

This is an opportunity to create a class that handles all this for you.

Posted: Fri Jan 07, 2005 6:19 pm
by markl999

Posted: Fri Jan 07, 2005 11:06 pm
by Trenchant
A temporary file may not be the best choice depending on what your doing. If you are just doing something like creating a specific saying on a certificate and then allowing a user to print it off or something like that where more than one user may access the page at once I would say use a database.

If not then I would say use feyd or marks suggestion.

Posted: Thu Jan 13, 2005 8:27 am
by waskelton4
Thanks for the replies!

I guess tmpfile is kindof what I was asking for however it turns out it isn't really what my application needs.

No worries. I'm just using the regular file handling functions to get what i need and will delete the files when i'm done. no big problem

thanks again for all the help!

ws