How to create folders and subfolders using PHP where user can give his own NAME for the folders and s开发者_Go百科ubfolders and number of folders that has to be created
<?php
$pathToDirCreationTopDir = '/var/www/path/to';
$mainDir = $_GET['mainDir'];
$subDirs = $_GET['subDirs'];
if (!mkdir($pathToDirCreationTopDir . '/' . $mainDir)) {
    echo 'Main dir creation failed!';
    exit;
}
$pathToDirCreationTopDir = $pathToDirCreationTopDir . '/' . $mainDir;
foreach ($subDirs as $subDirName) {
    if (!mkdir($pathToDirCreationTopDir . '/' . $subDirName)) {
        echo 'Sub dir creation failed!';
        exit;
    }
}
If you work on Windows you need to replace the slashes (/) with backslashes ()
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论