Hi i'm not able to test this on the server, but if folder date(Y) does not exist, is this coding write for it to be created. or do I have to do mkdir("/o_rec/" . date(Y) by itself first? Will supporting subfolders all be created if not present
if(!is_dir("/o_rec/" . date(Y) . "/" . date(m) . "/" . $id)) {
mkdir("/o_rec/" . date(Y) . "/" . date(m) . "/" . $id);
}
Building a structure with multiple subdirectories using mkdir requires adding the -p option. This makes sure that mkdir adds any missing parent directories in the process. Use ls -R to show the recursive directory tree.
We can use the -p option with the mkdir command to create a directory inside another directory. We can create nested directories without using this option too, but suppose we want to create a directory dataset inside a directory project and if there's no directory named project, then an error will occur.
The four subdirectories are created under the htg directory and then the two subdirectories, new and rewrites, are created under the articles subdirectory. It's that easy. You can also combine the mkdir command with the cd command to make a directory and change to it with one command.
A subfolder is a folder stored inside another folder. Subfolders help you organize your files more completely. Each subfolder should be used to store files related to each other. For example, you might have one folder for files related to a job search. Add subfolders for all of your files, such as family-related files.
bool mkdir ( string $pathname [, int $mode = 0777 [, bool $recursive = false [, resource $context ]]] )
you would need to set recursive to true
You should use set the "recursive" flag on you mkdir call to have it make the entire path you want.
http://php.net/manual/en/function.mkdir.php
Be advised that a google search makes it looks like there may be an existing bug, depending on your php version.
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