Create Delete Directory

	$dir = "myDirectory";
	/* Checking is directory exist or not */
	if(!is_dir($dir)) {
		/* Create directory with full access permission */
		$rs = mkdir($dir,0777) or die("Error...Not able to create directory!");
		if($rs == 1)
			echo "Directory created successfully!";
		echo "Directory already exist!";
	/* Checking is directory exist or not */
	if(is_dir($dir)) {
		/* Delete directory */
		$rs = rmdir($dir) or die("<br />Error...Not able to delete directory!");
		if($rs == 1)
			echo "<br />Directory deleted successfully!";
		echo "<br />Directory not found!";

/* Output */
Directory created successfully!

Directory deleted successfully!

Comments (0)

  • To add your comment please or

We use cookies to improve your experience on our site and to show you personalised advertising. Please read our cookie policy and privacy policy.

Got It!