简体   繁体   中英

How to retrieve(in controller) and display video in a Laravel Blade

I have successfully retrieved the video name with its extension from the database but it's not displaying on a blade. This the result when I retrive and dump

$video_data = DB::select('select * from videos')[4]->file?? null; dd($video_data);

"big_buck_bunny_720p_2mb.mp4"

Display in Laravel
<video width="320" height="240" controls>
 <source class="embed-responsive-item" src="{{URL('/storage/Atayads/Video/'.$video_data)}}" allowfullscreen>
</video>

Note I am displaying only one video that is according to an array above.

Now the problem I am getting that it's not displaying video, nor an error

Kindly help

Have you tried creating symbolic link according to laravel docs

php artisan storage:link

this will create a symlink from public/storage to storage/app/public & you can access the file from /storage/app/public

http://example.com/storage/big_buck_bunny_720p_2mb.mp4

for the full path you can use something like below

$path = storage_path('public/' . $video_data);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM