업데이트 페이지를 변경-이미지의 이름을 따라 동영상 id Laravel

0

질문

나는 원하는 이미지를 변경 이름을 따라 동영상 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;

          }
        }
file-upload laravel
2021-11-24 03:15:14
1

최고의 응답

0

코드

$video_themnull_name = uniqid() . Str::random('10') . '.' . $video_themnull->getClientOriginalExtension();

당신이 만들어 임의 파일 이름을 추가하려는 경우 동영상 id 를 가진 파일 이름은 그 다음에 추가해야 합$old_video->id 을 당신의 파일 이름을 창조이다. 시 다시 쓰기 위 코드는 아래와 같이

$video_themnull_name = $old_video->id. Str::random('10') . '.' . $video_themnull->getClientOriginalExtension(); 

추가 아래 코드가 내부에는 경우($video_themnull->isValid())조건

old_video->image_path = $image_path; 
$old_video->save(); 
2021-11-24 05:07:28

다른 언어로

이 페이지는 다른 언어로되어 있습니다

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................