How To Remove Directory Delete Directories Wiht PHP Code


How To Remove Directory Delete Directories Wiht PHP Code
  Forums Index
      » PHP Forums
        » » how to remove directory delete directories wiht PHP code



How To Remove Directory Delete Directories Wiht PHP Code
Post Description:
Post Tags: how, to, remove, directory, delete, directories, wiht, php, code, free php support, php scripts, php questions, php answers, programming, codes, scripts
This Post Has Been Viewed 440 Times Since Mon Mar 03, 2008 6:22 pm Posted By hostman with 2 replies
Next Post »» how to find in string finding value in string with PHP
How To Remove Directory Delete Directories Wiht PHP Code
deleting or removing directories or folders with php is simple

rmdir()


Removes directory

example, lets say i want to remove or delete a directory called images, this is how i would do it with php


$mydir = '/path/directory/images/';

rmdir($mydir);


thats it

but this would be a more practical use, first i want to check if the directory even exists:

$mydir = '/path/directory/images/';
if (is_dir($mydir)) {
rmdir($mydir);
} else {
echo $mydir.' does not exists';
}

Leave Your Comments
* Your Name

  * Your Email Address (Will Not Be Published)

* Your Comments


Add Picture To Comments
Yes No             upload
Receive Replies on my Comments
(An email will be sent to you when someone replies to your comments)

     




Comments and replies About How To Remove Directory Delete Directories Wiht PHP Code






:: 1 :: #69459 - Reply By Shoki On Fri Sep 05, 2008 8:00 am
you need to empty the directory first.
see unlink() function.
:: 2 :: #71561 - Reply By al On Sun Sep 21, 2008 10:56 pm
wouldnt your second script not work if the directory still has content? :)