1. Determine if there is
One:
if (@mkdir ("/img", 0700) {echo "OK";} Else{echo "Error";} There is output "OK", there is no output "error"
Two:
if (Is_dir ("/img")) {echo "OK";} Else{echo "Error";} There is output "OK", there is no output "error"
if (Is_dir ("img")) {echo "OK";} Else{echo "Error";} There is output "OK", there is no output "error"
2. When the folder does not exist, try to create it
One:
if (@mkdir ("path", 0700) {echo "OK";} Else{echo "Error";} Create successful output "OK", create failed or existing output "error"
if (@mkdir ("Aaa/ss", 0700) {echo "OK";} Else{echo "Error";} Create successful output "OK", create failed or existing output "error"
Two: A way to create a folder
function Mkdirs ($dir, $mode = 0777)
{
if (Is_dir ($dir) | | @mkdir ($DIR, $mode)) return TRUE;
if (!mkdirs (DirName ($dir), $mode)) return FALSE;
Return @mkdir ($dir, $mode);
}
Three. Determine if it exists and does not exist create:
$temp =true;
if (!is_dir (". /yitaoimg ")) {if (@mkdir (". /yitaoimg ", 0700)) {}else{$temp =false;}}
If there is no Yitaoimg folder under the IF ($temp) {}else{echo "relative path, and you do not have permission to create it, you may try to create it manually";}
3. An existing folder tries to delete it (an empty folder with appropriate permissions)
$path = "path";
if ([email protected] ($path))
{
Echo ("Delete failed! You may not have permissions, or delete the empty folder ");
}else{echo "Delete succeeded";}
This article is from "Buffy Rain Blog" blog, please be sure to keep this source http://bafeiyu.blog.51cto.com/5401101/1602459
Determine if a folder exists and does not exist create the folder