Archive for the ‘php’ Category

PHP Delete directory

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);
}

Donations appreciated. Every little $ helps. Or click Google +1

PHP Create directory

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
  }
}

Donations appreciated. Every little $ helps. Or click Google +1

PHP Delete file

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.";
  }
}

Donations appreciated. Every little $ helps. Or click Google +1

Related Posts with Thumbnails