cp2oss(_GALLERY_DIR); function cp2oss($directory) { $mydir = dir($directory); while($file = $mydir->read()) { if(is_dir("$directory/$file") && $file != "." && $file != "..") { cp2oss("$directory/$file"); } else if($file != "." && $file != "..") { $dir = ltrim(str_replace(_GALLERY_DIR, '', $directory),'/'); if(!OssUtil::fileExists(OSS_GALLERY_BUCKET, $dir."/".$file)){ echo($dir."/".$file."\n"); echo(_GALLERY_DIR.$dir.'/'.$file."\n"); OssUtil::uploadFileToBucket(OSS_GALLERY_BUCKET, $dir."/", $file, _GALLERY_DIR.$dir.'/'.$file); } } } $mydir->close(); }