I am working on Laravel 5.2. I have to display a video on my view page.I am able to store the video in my database table but, not able to fetch it and display it.I have the column in my table having the filepath of the videos which i am using to fetch it from the database.
My Controller:
public function talent(Request $request){
$user=new Talent();
$this->validate($request, [
'video'=>'required',
]);
$video=$request->file('video');
$filename=time().'.'. $video->getClientOriginalExtension();
$pathVideo = public_path('uploads/video/' . $filename);
Input::file('video')->move('uploads/video/', $pathVideo);
$user->file_path=$pathVideo;
$user->video=$filename;
$user->user_id=Auth::user()->id;
$user->save();
return redirect()->back();
}
public function talentpool($id){
$user=User::findorFail($id);
$talents=Talent::orderBy('created_at','desc')->get();
return view('talentpool',['user'=>$user,'talents'=>$talents]);
}
My View:
@foreach($talents as $talent)
<video width="616" src="{{ $talent->file_path }}" controls></video>
@endforeach
php.ini files contains some limits that might affect this. Try changing these to high enough values:
upload_max_filesize = 10M
post_max_size = 10M
memory_limit = 32M
@foreach($talents as $talent)
<video width="320" height="240" controls>
<source src="{{ $talent->file_path }}" type="video/mp4">
<source src="{{ $talent->file_path }}" type="video/ogg">
Your browser does not support the video tag.
</video>
@endforeach
If your path is not absolute use asset .