PHP – Check If Folder Exist


<?php
$dirname = $_POST[“DirectoryName”];
$filename = “/folder/{$dirname}/”;

if  (file_exists($filename)) {
echo “The directory {$dirname} exists”;
} else {
mkdir(“folder/{$dirname}”, 0777);
echo “The directory {$dirname} was successfully created.”;
}
?>

source:

http://www.dslreports.com/forum/r19705384-PHP-check-to-see-if-a-folder-exists

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s