Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- How do I find a writable directory ?
- Guillaume Dargaud
November 23, 2008, 7:01 pm
rate this thread
how can I write a (temporary) file to wherever it is allowed ?
On Linux, it's usually a safe bet to write to "/tmp", but on Windows, it
could be anywhere ("C:\Temp"...)
Is there a generic way to do this ?
Note that I don't want a temporary filename generator.
- Henrik Carlqvist
November 23, 2008, 7:47 pm
Re: How do I find a writable directory ?
In PHP version >= 5.2.1 there is a function called sys_get_temp_dir.
But if you have an older PHP, what about:
$writabledir = dirname(tempnam("", ""));
The above might not be foolprof though. I think that it might return /tmp
even though if you would happen to be on a web hotel where /tmp isn't
The address in the header is only to prevent spam. My real address is:
hc3(at)poolhem.se Examples of addresses which go to spammers:
- » I want to extract values in an array depending of a value.
- — Next thread in » PHP Scripting Forum