| 5:54 pm on Feb 14, 2011 (gmt 0)|
What you need to do is start a PHP session and use the session ID to identify your file.
Here's the docs on PHP session: [php.net...]
Alternatively, you could just randomly name the file using tempnam() [php.net] and that also solves the problem as each time you create the file the name is completely unique.
Either way you go, you will need to create some cron task to clean up all these files once a day because there will be failures which result in a backlog of old files clogging up the system.
| 2:43 am on Feb 15, 2011 (gmt 0)|
I decided to generate the file name using the php random number generator because the tempnam() function kept giving me the windows server system temp folder "C:\windows\temp\" as a directory even though I set the dir string in tempnam() to "/tmp" so the file would be created in the /tmp folder under the site root.
I have a feeling that the tempnam() dir parameter does not like relative paths.
I even tried using the full URL path "www.domain.com/tmp" as a dir in the tempnam() function but it still would not work.
| 5:12 am on Feb 15, 2011 (gmt 0)|
Random # isn't 100% unique - you could end up overwriting the same file depending on the volume of requests and how it's seeded.
I use the tempnam() in Linux and crank about about 50K temp names a day, it works really well.
Perhaps the tempnam() problem is your mixing of "/" and "\" or perhaps try ".\temp"
| 6:42 am on Feb 15, 2011 (gmt 0)|
My development server is a windows 7 x64 machine.
I tried your suggestions, but i still get "C:\Windows\Temp\". According to the php doc's, if the specified directory does not exist, tempnam() may generate a file in the system's temporary directory, and return the name of that.
the "/tmp" folder i'm trying to write a tmp file into exists in the development sites root directory "client". The complete system path on the development web server is "D:\Webserver\Apache\development\client\tmp". Maybe i'm just not specifying the tempnam dir parameter right.
I guess i could try and just use tempnam() with some string functions to extract the unique id and then append the file prefix and type to it.
| 7:16 am on Feb 15, 2011 (gmt 0)|
Try specifying the full path if all else fails, sounds like a rights issue on the /tmp path possibly
| 8:37 am on Feb 15, 2011 (gmt 0)|
The issue is me! Apparently i tried everything - but - "./tmp" in tempnam(). It now works and finds the correct development site root path.
Sorry about that...
Unfortunately, since tempnam() creates the file by default with the ".tmp" file extension, I now have to rename the file to change the file type to ".html".
Kind of messy, but problem solved - thanks again!