php - is_dir () function is case sensitive -
below code
<?php $folder_type=$_post['folder_type']; $folder_name=$_post['folder_name']; $images="images"; $path="../../".$folder_type."/".$folder_name; if (!is_dir("../../".$folder_type."/".$folder_name)) { mkdir("../../".$folder_type."/".$folder_name); mkdir("../../".$folder_type."/".$folder_name."/".$images); $content = file_get_contents('../../default_code.php'); $fp = fopen($path . "/$folder_name.php","wb"); fwrite($fp,$content); fclose($fp); } else { echo "0"; } chmod("../../".$folder_type."/".$folder_name, 0777); ?>
if directory having foldername name alto , if tried new folder name alto won't accept right bt is_dir() function not checking casesensitive. if tried alto won't accept. there other way checking whether new foldername present in directory or not?
please anyone. in advance.
you can use strtolower
,so create lowercase folder , have no worries in dir checking
$folder_type=$_post['folder_type']; $folder_name=$_post['folder_name']; $folder_type = strtolower( $folder_type ); $folder_name = strtolower( $folder_name ); $images="images"; $path="../../".$folder_type."/".$folder_name; if (!is_dir("../../".$folder_type."/".$folder_name)) { mkdir("../../".$folder_type."/".$folder_name); mkdir("../../".$folder_type."/".$folder_name."/".$images); $content = file_get_contents('../../default_code.php'); $fp = fopen($path . "/$folder_name.php","wb"); fwrite($fp,$content); fclose($fp); } else { echo "0"; } chmod("../../".$folder_type."/".$folder_name, 0777);
Comments
Post a Comment