Hot to create a folder using PHP in a subdirectory?


I am trying to use PHP command to create a folder in the same folder as the command-file is run.
This worked when the PHP command script was located in public_html aka top level directory.

However when locating this working code into a sub-directory, it is giving an error on this part of the code: 0777
This number is a file permission. Does mean it doesn’t have permission to write to sub-folders?

Warning: mkdir(): No such file or directory in /storage/h10/365/1360365/public_html/LR/CreateSubfolder.php on line 11
Failed to create directory…

Actual code that runs, but only in the top level directory:


$thisdir = getcwd();
$new_dir = ‘145’;

$thisdir .
“LR/upload/” .
// creates a subfolder called “upload” and a new file called “145”
echo “Directory has been created successfully…”;
echo “Failed to create directory…”;


So I was reading here:

And I added “, true” right affter the 0777, inside the mkdir() parenthesis. and the command runs now.

Problem Solved.