public static function moved_file($tmpdir, $newdir, $pack) { //return rename( $tmpdir, $newdir ); $list = rglob($tmpdir . '*', GLOB_BRACE); //var_dump( $list ); //exit; //批量迁移文件 foreach ($list as $file) { $newd = str_replace($tmpdir, $newdir, $file); //var_dump( $file ); //var_dump( $newd ); //echo '<hr />'; if (file_exists($file) && is_writable($file) == FALSE) { //记录在案 self::$lastfile = str_replace($tmpdir, '', $file); return -10007; } //////////////////////////// if (file_exists($newd) && is_writable($newd) == FALSE) { //记录在案 self::$lastfile = str_replace($newdir, '', $newd); return -10007; } //////////////////////////// //创建文件夹 if (is_dir($file)) { create_dir($newd, TRUE, 0777); } else { //删除旧文件(winodws 环境需要) if (file_exists($newd)) { unlink($newd); } //生成新文件 $test = @rename($file, $newd); //记录在案 self::$lastfile = str_replace($tmpdir, '', $file); } //////////////////////////// //移动文件出错 if ($test === FALSE) { return -10005; } } //删除临时目录 delete_dir($tmpdir); //删除文件包 unlink(self::get_pack_file($pack)); return count($list); }