Looping through the creation of directory methods
This will generate the Image.gif directory
Copy the Code code as follows:
$filepath = "Test/upload/2010/image.gif";
Mk_dir ($filepath);
Looping through the creation of catalogs
function Mk_dir ($dir, $mode = 0755)
{
if (Is_dir ($dir) | | @mkdir ($DIR, $mode)) return true;
if (!mk_dir (DirName ($dir), $mode)) return false;
Return @mkdir ($dir, $mode);
}
The second method:
Copy the Code code as follows:
$filepath = "Test/upload/2010/image.gif";
Createdir (DirName ($filepath));
The next thing you can do is move_uploaded_file!
/*
* Function: Loop Detect and Create folder
* Parameters: $path folder path
Returns
*/
function Createdir ($path) {
if (!file_exists ($path)) {
Createdir (DirName ($path));
mkdir ($path, 0777);
}
}
?>
The above describes whether I really have nothing lyrics PHP loop to detect whether the directory exists and create a loop to create a directory, including whether I do not have the lyrics of the content, I hope to be interested in PHP tutorial friends helpful.