フォルダーの有無を判定し、フォルダーを作成する


フォルダーの有無を判定し、フォルダーを作成する

check_folder(新規に作成するフォルダー名,フルパス名);

フルパス名 = $_SERVER["DOCUMENT_ROOT"];
新規フォルダー = "/new/folder/create";

//***************************************
// フォルダーの作製
//***************************************
function check_folder($newfolder="",$path="") {

	global $CONFIG;

	$folder = explode("/",$newfolder);

	$current_folder ="";
	foreach($folder as $key=>$val) {

		$current_folder = $current_folder."/".$val;

		$check_folder_name = $path.$current_folder;

		if (!is_dir($check_folder_name)) {

			if (!mkdir($check_folder_name)) {
				echo "Directory の作製に失敗".$check_folder_name;
				exit;
			}

			if (!chmod($check_folder_name, 0777)) {
				echo "CHMOD の作製に失敗".$check_folder_name;
				exit;
			}

		}

	}

}

コメント

タイトルとURLをコピーしました