I am using XMPP
server in windows 7 for executing PHP script. I have project folder in htdocs
which contain my projects PHP script with required bootstrap, CSS and jquery files. I have three subfolders in the project folder as student
, teacher
, and admin
. I have one folder as the report in admin. I am working in student folder, How to create report directory in admin folder if report folder does not exist?
I want to create folder or Director in parent folder's not in the same folder.
If you want to get the parent directory you can use the function dirname
. In your example it would look as follows:
$rebuilt_dir = "../admin/report";
$parent_dir = dirname($rebuilt_dir);
if(!is_dir($parent_dir)) {
if(!mkdir($parent_dir))
echo "Error creating dir: ".$!;
if(!is_dir($rebuilt_dir)) {
if(!mkdir($rebuilt_dir))
echo "Error creating dir: ".$!;
}