PHP Delete directory
Posted by tech on
March 24, 2008
Deletes a directory in the server’s file system.
function deleteDirectory($dir, $DeleteMe) {
if(!$dh = @opendir($dir)) return;
while (false !== ($obj = readdir($dh))) {
if($obj=='.' || $obj=='..') continue;
if (!@unlink($dir.'/'.$obj)) SureRemoveDir($dir.'/'.$obj, true);
}
closedir($dh);
if ($DeleteMe){
@rmdir($dir);
}
tags: delete directory
No Comments
PHP Create directory
Posted by tech on
March 24, 2008
Creates a directory in the server’s file system.
function makeDirectory($path) {
if (!is_dir($path)) {
$oldumask = umask(0);
mkdir($path, 0777);
umask($oldumask);
chmod($path, 0777); // octal; correct value of mode
}
}
tags: create directory
3 Comments
PHP Delete file
Posted by tech on
March 24, 2008
Delete a file in the file system. Note that this file system we’re talking about is the server’s file system. PHP nor other web-based programming language deletes a file system on the client’s side.
function deleteFile($filename) {
$do = unlink($filename);
if ($do=="1") {
echo "The file was deleted successfully.";
} else {
echo "There was an error trying to delete the file.";
}
}










