[SOLVED] programatically creating a temporary file

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
waskelton4
Forum Contributor
Posts: 132
Joined: Mon Sep 09, 2002 6:42 pm

[SOLVED] programatically creating a temporary file

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

User avatar
Trenchant
Forum Contributor
Posts: 291
Joined: Mon Nov 29, 2004 6:04 pm
Location: Web Dummy IS

Post 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.
waskelton4
Forum Contributor
Posts: 132
Joined: Mon Sep 09, 2002 6:42 pm

Post 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
Post Reply