修改名字
This commit is contained in:
parent
ef1b14fe54
commit
174b8f3438
|
|
@ -50,7 +50,7 @@ class FileManagerController extends Controller
|
||||||
$originPath = $request->get('origin_name');
|
$originPath = $request->get('origin_name');
|
||||||
$newPath = $request->get('new_name');
|
$newPath = $request->get('new_name');
|
||||||
(new FileManagerService)->updateName($originPath, $newPath);
|
(new FileManagerService)->updateName($originPath, $newPath);
|
||||||
return json_success('删除成功');
|
return json_success('修改成功');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -116,10 +116,14 @@ class FileManagerService
|
||||||
public function updateName($originPath, $newPath)
|
public function updateName($originPath, $newPath)
|
||||||
{
|
{
|
||||||
$originPath = public_path("catalog/{$originPath}");
|
$originPath = public_path("catalog/{$originPath}");
|
||||||
$newPath = public_path("catalog/{$newPath}");
|
|
||||||
if (!is_dir($originPath) || !file_exists($originPath)) {
|
if (!is_dir($originPath) || !file_exists($originPath)) {
|
||||||
throw new \Exception('原始文件或者文件夹无效');
|
throw new \Exception('原始文件或者文件夹无效');
|
||||||
}
|
}
|
||||||
|
$originBase = dirname($originPath);
|
||||||
|
$newPath = $originBase . '/' . $newPath;
|
||||||
|
if ($originPath == $newPath) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
@rename($originPath, $newPath);
|
@rename($originPath, $newPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue