param($targetFile)->water($targetFile,$water,9); echo get_relative_path($targetFile); } function new_name($filename){ $ext = pathinfo($filename); $ext = $ext['extension']; $name = basename($filename,$ext); $name = md5($name.time()).'.'.$ext; return $name; } function get_relative_path($path,$dir = 'data'){ $strlen = strlen(substr(__BASE__, 0, 17)); $path = substr($path, $strlen); return '/'.substr($path,strpos($path,$dir),strlen($path )); } function recurDirs($path, $isFile = false, $mode = 0777) { $dirArr = explode('/', $path); if (!is_array($dirArr) || empty($dirArr)) { return false; } // 过滤掉空目录 // $dirArr = Libs_Filter::clearEmptyValue($dirArr); if ($isFile) { array_pop($dirArr); } $dirStr = ''; foreach ($dirArr as $dir) { $dirStr .= '/' . $dir; if (!is_dir($dirStr)) { // @mkdir($dirStr, $mode, true); exec("mkdir -p {$dirStr}",$outPut,$returnVar); @chmod($dirStr, $mode); } } if ($isFile) { if (!file_exists($path)) { @touch($path, $mode); @chmod($path, $mode); } } return true; } ?>