![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
King of Portal
|
Determine filename of tmpfile()
Is there any way possible to determine the filename of a file created by the function tmpfile()?
On the PHP site they show you a way to determine the path to the temporary folder but how do I obtain the filename (assuming that's even possible)? The fstat() function doesn't seem to yield anything about the filename. Any ideas?
__________________
Lo, there do I see my father. 'Lo, there do I see My mother, and my sisters, and my brothers. 'Lo, there do I see The line of my people... Back to the beginning. 'Lo, they do call to me. They bid me take my place among them. In the halls of Valhalla... Where the brave... May live... ...forever.. GrimBB | Mimesis |
|
|
|
|
|
#2 |
|
Programming Guru
![]() ![]() |
Re: Determine filename of tmpfile()
What if there is more than one temp file, how are you even deciding which one to choose?
|
|
|
|
|
|
#3 |
|
Programmer
Join Date: Nov 2007
Posts: 86
Rep Power: 1
![]() |
Re: Determine filename of tmpfile()
if you need to know the name of the tempfile, you should use the tempnam function to get the name of a unique file, then fopen it.
|
|
|
|
|
|
#4 |
|
Programming Guru
![]() ![]() |
Re: Determine filename of tmpfile()
I think grimpirate is referring to this as a continuation of his "flock" thread. He needs to know how to recall the name of the temporary file from a new PHP instance. I think?
Could you clarify, grimpirate? ![]() |
|
|
|
|
|
#5 |
|
King of Portal
|
Re: Determine filename of tmpfile()
You're absolutely right Sane I couldn't determine which file it is that is being created I mean the only thing I can tell is that the file starts with a prefix of 'php', then some hex characters, and the extension '.tmp'. But if more than one is created how would I know which one it is? I was stating that as an aside regarding my train of thought/advancements (which isn't anything really). I agree with what mbd is saying in the sense that tempnam() does return the unique filename to me. However, tmpfile() has one explicit condition which is that it's removed in case of an abnormal script failure. With tempnam() I imagine I would have to code some sort of register_shutdown_function() and I'm not entirely sure how I would deal with errors and such in there (should they transpire). With tmpfile() I'm more comfortable in saying that since it is a hard-coded aspect of the php language the file would definitely be removed.
__________________
Lo, there do I see my father. 'Lo, there do I see My mother, and my sisters, and my brothers. 'Lo, there do I see The line of my people... Back to the beginning. 'Lo, they do call to me. They bid me take my place among them. In the halls of Valhalla... Where the brave... May live... ...forever.. GrimBB | Mimesis |
|
|
|
|
|
#6 |
|
King of Portal
|
Re: Determine filename of tmpfile()
Figured it out: you use the stream_get_meta_data() function and then access the 'uri' key in the output array
__________________
Lo, there do I see my father. 'Lo, there do I see My mother, and my sisters, and my brothers. 'Lo, there do I see The line of my people... Back to the beginning. 'Lo, they do call to me. They bid me take my place among them. In the halls of Valhalla... Where the brave... May live... ...forever.. GrimBB | Mimesis |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Determine RightToLeft Settings | ChiHappens | C# | 1 | Mar 18th, 2006 2:27 PM |
| question about filename in common dialog | Kilo | Visual Basic | 4 | Nov 28th, 2005 4:42 AM |
| How to determine if it's a word | aznluvsmc | C | 10 | Aug 22nd, 2005 12:30 PM |
| Resolving Filename From Dynamic Download Page | slugonamission | Delphi | 0 | Jul 18th, 2005 4:09 PM |
| Filename expansion problems in script | msalowit | Bash / Shell Scripting | 1 | Apr 15th, 2005 11:21 AM |