Create Folder Recursive PHP

How to automatically create folder if not exists on spesific PATH
Bagaimana cara membuat folder secara rekursif bila tidak ada pada spesifik PATH
<?php
//define document root first define document root dahulu
define('APP', $_SERVER['DOCUMENT_ROOT'], true);
// [func] path extraction and creation
function _folder_($d){
    $d = str_replace(APP, '', rtrim($d, '/'));
    $explode = explode('/', rtrim($d,'/'));
    $explode = array_filter($explode);
    $ready = (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN' ? '' : '/');
    foreach ($explode as $x) {
      $ready = rtrim($ready,'/');
      $ready .= '/'.$x;
      $status = file_exists(APP.$ready);
      if ($status === false){
        mdir(APP.$ready);
      }
    }
    return $d;
}
// [func] create folder permission 777
function mdir($x)
{
  $oldmask = umask(0);
  mkdir($x, 0777);
  umask($oldmask);
}

//Usage Penggunaan
$folder_target = 
?>

Subscribe to receive free email updates:

0 Response to "Create Folder Recursive PHP"

Post a Comment

Bila Ada posting yang kurang, atau error atau yang lainnya, silahkan tinggalkan komentar agar artikel/post di perbaiki.
Jangan Lupa Cek Box "Notify Me" agar tahu komentar kamu dibalas oleh saya.

If there are any posts that are missing, or error or anything else, please leave a comment for the article / post to be fixed.
Do not Forget Check Box "Notify Me" to know our comments replied by me.