I've got the following piece of code on a PHP 5.2.4 (no safe_mode) linux server:
mkdir( $path, 0777, true );
when I enter a path like:
'/path/to/create/recur/ively/'
all directories are created except for the last one... when I add another directory like:
'/path/to/create/recur/ively/more/'
again, all paths are created except for the last one...
have tried both with and without trailing slashes
Can any1 enlighten me here please?
You'll get this error if you make the silly mistake I did and pass a string, rather than the numeric literal for mode.
mkdir( $path, "0777", true ); // BAD - only creates /a/b
mkdir( $path, 0777, true ); // GOOD - creates /a/b/c/d
The intermediate directories created are set based on the current umask. You want something like this
umask(0777);
mkdir($path, 0777, true);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With