php库自带有判断文件或目录是否存在的函数,file_exists判断文件是否存在,is_dir判断目录(文件夹)是否存在。具体示例如下:
$file='index.php';
$dir='www.feishuai.vip/wwwroot/';
if(file_exists($dir.$file)){
echo '文件'.$file.'存在';
}else{
echo '文件'.$file.'不存在';
}
if(is_dir($dir)){
echo '目录'.$dir.'存在';
}else{
echo '目录'.$dir.'不存在';
}