Я использую следующее для создания каталога в приложении интрасети для каждого клиента. Проблема в том, что если каталог уже существует, я получаю сообщение об ошибке:
Warning: mkdir() [function.mkdir]: File exists in C:\server2go\server2go\htdocs\customermgr\administrator\components\com_chronoforms\form_actions\custo m_code\custom_code.php(18) : eval()'d code on line 11
Failed to create directory...
Возможно ли, чтобы сценарий не создал каталог, если он уже существует?
<?php
$customerID = $_GET['cfid'];
/* wherever this particular script will be installed, I want to create a subfolder */
/* Step 1. I need to know the absolute path to where I am now, ie where this script is running from...*/
$thisdir = getcwd();
/* Step 2. From this folder, I want to create a subfolder called "myfiles". Also, I want to try and make this folder world-writable (CHMOD 0777). Tell me if success or failure... */
if(mkdir($thisdir ."/customer-files/$customerID" , 0777))
{
echo "Directory has been created successfully...";
}
else
{
echo "Failed to create directory...";
}
?>
РЕДАКТИРОВАТЬ >>>>>>>>>>>>>
Я пробовал следующее, но все равно не радости: - (
<?php
$customerID = $_GET['cfid'];
$directory = "/customer-files/$customerID";
if(file_exists($directory) && is_dir($directory)) {
}
else {
/* wherever this particular script will be installed, I want to create a subfolder */
/* Step 1. I need to know the absolute path to where I am now, ie where this script is running from...*/
$thisdir = getcwd();
/* Step 2. From this folder, I want to create a subfolder called "myfiles". Also, I want to try and make this folder world-writable (CHMOD 0777). Tell me if success or failure... */
if(mkdir($thisdir ."/customer-files/$customerID" , 0777))
{
echo "Directory has been created successfully...";
}
else
{
echo "Failed to create directory...";
} }
?>