PHP Scripting

Create Delete Directory

create directory and delete directory in PHP

6/21/2020
0 views
php-create-delete-directory.phpPHP
<?php
	$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!";
	}
	else
		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!";
	}
	else
		echo "<br />Directory not found!";
?> 




/* Output */
Directory created successfully!

Directory deleted successfully!
PHPcreate directory in PHPdelete directory in PHPmkdirrmdir

Related Examples

Mashable is a global, multi-platform media and entertainment company For more queries and news contact us on this
Email: info@mashablepartners.com