Loop creation directory method
This will generate the image.gif directory
Copy the code The code is as follows:
$ filepath = "test/upload/2010/image.gif";
mk_dir($filepath);
// Loop to create directories
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);
}
Second method:
Copy code The code is as follows:
$filepath = "test/upload/2010/image.gif";
createDir(dirname($filepath));
//Next You can move_uploaded_file!
/*
* Function: Loop to detect and create folders
* Parameters: $path Folder path
* Return:
*/
function createDir($path ){
if (!file_exists($path)){
createDir(dirname($path));
mkdir($path, 0777);
}
}
? >
http://www.bkjia.com/PHPjc/322877.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/322877.htmlTechArticleLoop directory creation method This will generate the image.gif directory copy code The code is as follows: $filepath = "test/upload/ 2010/image.gif"; mk_dir($filepath); // Loop to create directory function mk_di...