예제 #1
0
 /**
  * buildDirs - Recursively build a directory structure.
  *
  * @param	string	Path that needs to be created.
  * @param	string	Folder permissions in octal format.
  * @return 	boolean
  **/
 function buildDirs($dir, $mode = 0755)
 {
     if (is_dir($dir) || @mkdir($dir, $mode)) {
         return true;
     }
     if (!NFilesystem::buildDirs(dirname($dir), $mode)) {
         return false;
     }
     return @mkdir($dir, $mode);
 }
예제 #2
0
 public static function moveUpload($src, $target)
 {
     $rel_path = implode('/', array(trim(self::$prefix, '/'), trim($target, '/')));
     $abs_path = '/' . implode('/', array(trim(DOCUMENT_ROOT, '/'), trim($rel_path, '/')));
     $dir = pathinfo($abs_path, PATHINFO_DIRNAME);
     NFilesystem::buildDirs($dir);
     if (move_uploaded_file($src, $abs_path)) {
         return '/' . $rel_path;
     } else {
         throw new NUploadException("Could not move file: {$src} to {$target}", 1);
     }
 }