how can I save an uploaded video to the public path? I usually deal with Images and use the Image Intervention Package which only works for images so I don't know how to possibly save a video. Here's what I tried (doesn't work):
$video = $request->file('video');
$vid_name = hexdec(uniqid()) . '.' . $video->getClientOriginalExtension();
Image::make($video)->save('uploads/about/experience_us/' . $vid_name);
$vid_url = 'uploads/about/experience_us/' . $vid_name;
ExperienceUs::updateOrCreate([
'video' => $vid_url,
]);
The save()
method comes with the Image Intervention as stores the file in the public path.
CodePudding user response:
You can use this
$vid_url = 'uploads/about/experience_us/' . $vid_name;
\Storage::disk('public')->put($vid_url , file_get_content($video));
CodePudding user response:
Try this :
$video = $request->file('video');
$vid_name = hexdec(uniqid()) . '.' . $video->getClientOriginalExtension();
$file->move(public_path('uploads/about/experience_us/' ), $vid_name); // changed line
$vid_url = 'uploads/about/experience_us/' . $vid_name;
ExperienceUs::updateOrCreate([
'video' => $vid_url,
]);
i hope it was useful