我想改变形象的姓名按照视频id在Laravel项目。 如何解决这个?
这里是代码的控制器
$old_video = Video::find($id);
//video thumbnail uploaded
if ($request->hasFile('image_path') != '') {
$video_themnull = $request->file('image_path');
$video_themnull_name = uniqid() . Str::random('10') . '.' . $video_themnull->getClientOriginalExtension();
$video_themnull_resize = Image::make($video_themnull->getRealPath());
$video_themnull_resize->resize(400, 200);
if ($video_themnull->isValid()) {
if (isset($old_video->image_path)) {
$files_old = $old_video->image_path;
if ( file_exists($files_old)) {
unlink($files_old);
}
}
$video_themnull_resize->save(public_path('video/themnull/' . $video_themnull_name));
$image_path = 'public/video/themnull/' . $video_themnull_name;
}
}