If you have a site with large number of users where they upload pictures or documents or videos, then you should create directories during run-time.

The function 'mkdir' creates a directory in the specified path. The following are the parameters of creating a directory:

1.pathname: Specified path of the directory
2.mode: The default mode is 0777.

Example: Let us create a dynamic directory based on the current date.

function createNewDirectory()

{

$sCurrDate = date("Y-m-d"); //Current Date$sDirPath = 'http://example.com/files/'.$sCurrDate.'/'; //Specified Pathname if (!file_exists ($sDirPath))

{

mkdir(\$sDirPath,0777,true);

}

}

The above function will create a dynamic directory on the server. The path of the created directory will be: https://example.com/files/2015-10-12 provided the current date is Oct 12, 2015.