我正在尝试验证:我尝试创建的文件夹是否存在。当然,我收到一条消息......一条错误消息:/告诉我它确实如此!(如果它不存在,则没有错误消息,并且一切都按计划进行)。
它输出此错误消息
Directory exists
Warning: mkdir() [function.mkdir]: File exists in /home/***/public_html/***/formulaires/processForm-test.php on line 75
UPLOADS folder has NOT been created
我使用的当前代码是这个:
$dirPath = $_POST['company'];
if(is_dir($dirPath))
echo 'Directory exists';
else
echo 'directory not exist';
function ftp_directory_exists($ftp, $dirPath)
{
// Get the current working directory
$origin = ftp_pwd($ftp);
// Attempt to change directory, suppress errors
if (@ftp_chdir($ftp, $dirPath))
{
// If the directory exists, set back to origin
ftp_chdir($ftp, $origin);
return true;
}
// Directory does not exist
return false;
}
$result = mkdir($dirPath, 0755);
if ($result == 1) {
echo '<br/>'.$dirPath . " has been created".'<br/>';
} else {
echo '<br/>'.$dirPath . " has NOT been created".'<br/>';
}
我最近添加了中间部分(我不知道这是否会产生影响)。以“function ftp_directory_exists($ftp, $dirPath)”开头的那个