我将使用以下内容为每个客户在内部网络应用程序上创建目录。问题是,如果该目录已经存在,我会收到错误提示:
脚本是否可以在目录已存在的情况下不创建该目录?或者不显示错误信息?
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...";
} }
?>