Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jan 16th, 2008, 12:12 PM   #1
grimpirate
King of Portal
 
grimpirate's Avatar
 
Join Date: Sep 2005
Posts: 437
Rep Power: 4 grimpirate is on a distinguished road
Send a message via Yahoo to grimpirate
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
grimpirate is offline   Reply With Quote
Old Jan 16th, 2008, 12:37 PM   #2
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Location: Waterloo, Ontario
Posts: 2,034
Rep Power: 6 Sane will become famous soon enough
Send a message via MSN to Sane
Re: Determine filename of tmpfile()

What if there is more than one temp file, how are you even deciding which one to choose?
Sane is online now   Reply With Quote
Old Jan 16th, 2008, 2:17 PM   #3
mbd
Programmer
 
Join Date: Nov 2007
Posts: 86
Rep Power: 1 mbd is on a distinguished road
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.
mbd is offline   Reply With Quote
Old Jan 16th, 2008, 2:25 PM   #4
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Location: Waterloo, Ontario
Posts: 2,034
Rep Power: 6 Sane will become famous soon enough
Send a message via MSN to Sane
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?
Sane is online now   Reply With Quote
Old Jan 16th, 2008, 5:07 PM   #5
grimpirate
King of Portal
 
grimpirate's Avatar
 
Join Date: Sep 2005
Posts: 437
Rep Power: 4 grimpirate is on a distinguished road
Send a message via Yahoo to grimpirate
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
grimpirate is offline   Reply With Quote
Old Jan 18th, 2008, 2:48 PM   #6
grimpirate
King of Portal
 
grimpirate's Avatar
 
Join Date: Sep 2005
Posts: 437
Rep Power: 4 grimpirate is on a distinguished road
Send a message via Yahoo to grimpirate
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
grimpirate is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

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




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 10:11 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC