사용자가 인터페이스를 통해 카테고리 및 섹션을 동적으로 생성 할 수있는 컨텐츠 관리 시스템을 만들고 있습니다. PHP와 MySQL을 기반으로합니다 - 사용자가 양식을 클릭하여 데이터베이스에 사용자 정보를 제출하면 디렉토리가 존재하지 않는 경우 디렉토리와 이미 존재하지 않는 경우 색인 파일이 동적으로 생성됩니다. 또한, 사용자는 동시에 생성되는 생성되는 섹션에 대응하는 특정 파일을 지정할 수있다.스크립트가 성공하더라도 mkdir() 경고 발생
필자가 얻었던 모든 것 : 디렉토리, 색인 파일 및 섹션 파일이지만 mkdir() 경고 오류가 발생했습니다. 경고는 "경고 : mkdir() [function.mkdir] : File in .."이며 mkdir 함수가 나타나는 행을 나타냅니다. file_exists() 함수를 사용하여 디렉토리 및 색인 파일이 아직 존재하지 않는지 확인했지만 작동하지 않는 것으로 나타납니다. 어떤 아이디어?
내 코드는 다음과 같습니다
$dir = $category."/";
if (file_exists($_SERVER['DOCUMENT_ROOT'].$dir)) {
chdir($dir);
$newFileName = $link_name.".php";
$newFileHandle = fopen($newFileName, 'w+') or die("can't open file");
$category = $_POST['category'];
$category = strtoupper($category);
fwrite($newFileHandle, implode("\r\n", $content));
fwrite($newFileHandle, '"'.$category.'"'.';');
fwrite($newFileHandle, implode("\r\n", $php_cat_content));
fwrite($newFileHandle, '"'.$section_name.'"'.';');
fwrite($newFileHandle, implode("\r\n", $php_sec_content));
fclose($newFileHandle);
}
else {
$dir = str_replace (" ", "", $category) ."/";
mkdir($dir, 0777);
chdir($dir);
if (!file_exists("index.php")) {
$index_fn = "index.php";
$index_fh = fopen($index_fn, 'w+') or die("can't open file");
$category = $_POST['category'];
$category = strtoupper($category);
fwrite($index_fh, implode("\r\n", $content));
fwrite($index_fh, '"'.$category.'"'.';');
fwrite($index_fh, implode("\r\n", $php_cat_content));
fwrite($index_fh, '"'.$section_name.'"'.';');
fwrite($index_fh, implode("\r\n", $php_sec_content));
fclose($index_fh);
}
else {
$newFileName = $link_name.".php";
$newFileHandle = fopen($newFileName, 'w+') or die("can't open file");
$category = $_POST['category'];
$category = strtoupper($category);
fwrite($newFileHandle, implode("\r\n", $content));
fwrite($newFileHandle, '"'.$category.'"'.';');
fwrite($newFileHandle, implode("\r\n", $php_cat_content));
fwrite($newFileHandle, '"'.$section_name.'"'.';');
fwrite($newFileHandle, implode("\r\n", $php_sec_content));
fclose($newFileHandle);
}
내가 적절한 자리에 is_dir()와() file_exists를 대체하고있어 (내가 생각하는)이어야
$_SERVER['DOCUEMENT_ROOT'] . "/"
누락 발견 유사한 결과가 아닌 경우에도 마찬가지입니다. 그게 네 생각이야? file_exists()를 is_dir()으로 대체 하시겠습니까? – jbrown574@ jbrown574 : 귀하의 파일은 조건부에 체크인하는 것과는 다른 위치에 저장되어있을 가능성이 큽니다. – animuson