I can successfully upload my video with the below code. But when i display the video in the view page it's blank.
public function store(Request $request)
{
if(Auth::check())
{
if(Input::hasFile('video'))
{
$file = $request->file('video');
$videomimes = ['video/mp4'];
if (in_array($file->getMimeType() ,$videomimes)) {
$filevalidate = 'required|mimes:mp4';
}
$this->validate($request, [
'video' => $filevalidate,
]);
$filename = 'Tag '.$request->input('tag_no').'.'.$file->getClientOriginalExtension();
$request->death_video->move(public_path('/storage/videos'), $filename);
$stock = Stock::create([
'tag_no' => $request->input('tag_no'),
'video'=> $filename,
'user_id' => Auth::user()->id
]);
if($stock){
return redirect()->route('stocks.index')
->with('success' , 'Stock created successfully');
}
}
}
return back()->withInput()->with('errors', 'Error creating new Stock');
}
This is my schema:
Schema::create('stocks', function (Blueprint $table) {
$table->increments('tag_no');
$table->binary('video');
$table->integer('user_id')->unsigned();
$table->foreign('user_id')->references('id')->on('users');
$table->timestamps();
});
This is how i display video:
<video width="320" height="240" controls>
<source src="/storage/videos/" type="video/mp4">
Your browser does not support the video tag.
</video>
I can hear the audio but no visual is shown! How to solve this?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire