i m trying to check and make muliple dir in a single command by mkdir command bt nt get success, is there any alternative or how to use it. . Ex- file/a/b/c i want to if there a,b or c dir present if nt create which is nt present. If a, present bt b,c nt then create b and c both.. Pls share if u knw the solution .. At present i m using loop to do this .
how to use mkdir in php
Started on the old forum in June 2012 · view the original in the archive · old links redirect here
Make an array with a b c names, do foreach() loop with if() and is_dir(), and if it returns true set continue; else mkdir(). Check this for start: http://coding-talk.com/f46/source-codes-small-scripts-360/index12.html#post97296
<!DOCTYPE html PUBLIC "-//***WAPFORUM**.**RS***
try this
<?php
// Desired folder structure
$structure = './depth1/depth2/depth3/';
// To create the nested structure, the $recursive parameter
// to mkdir() must be specified.
if (!mkdir($structure, 0, true)) {
die('Failed to create folders...');
}
// ...
?>
Added after 6 minutes:
Try this 101% working
<?php
$foldername="hello";
mkdir("$foldername", 0777); // create folder
chmod( "$foldername", 0777 ); // chmod folder to 0777
mkdir("$foldername/pics", 0777); // create folder
chmod("$foldername/pics", 0777 ); // chmod folder to 0777
echo"Sucessfully created";
?>