Creating a Directory in PHP

Q

How To Create a Directory in PHP?

✍: FYIcenter.com

A

You can use the mkdir() function to create a directory. Here is a PHP script example on how to use mkdir():

<?php 
if (file_exists("/temp/download")) {
  print("Directory already exists.\n");
} else {
  mkdir("/temp/download");
  print("Directory created.\n");
}
?>

This script will print:

Directory created.

If you run this script again, it will print:

Directory already exists.

 

Working with Directoris and Files in PHP

⇒⇒PHP Tutorials

2016-11-24, 302👍, 0💬