skip to Main Content

I have a project which contains some video files in storage/app/public/homepage/
The files are really there and in html there is something like

<video autoplay muted loop>
    <source src="http://localhost:8000/storage/homepage/vid3.mp4" type="video/mp4" />
</video>

But video does not play. I tried to run php artisan storage:link but it wrote

publicstorage] link already exists. The links have been created.

So I run php artisan serve but can not see the video on localhost. Network shows error 404 not found.
What am I doing wrong? Project is pretty old and everything worked till this day. I did not make any changes.
Thanks for help.

2

Answers


  1. Is asset() helper function available in Laravel 7? If so perhaps try using that

    <video autoplay muted> <source src="{{ asset('homepage/vid3.mp4')}}"></video>
    
    Login or Signup to reply.
  2. <video autoplay muted loop>
        <source src="{{ asset('storage/homepage/vid3.mp4') }}" type="video/mp4">
    </video>
    

    Explanation:

    1. The base directory for the asset() helper function is the ‘public’ folder.
    2. In the public folder, a ‘storage’ symlink is created and this symlink remains such that it points to ‘storage/app/public’.
    3. Therefore, if we were to use asset() to point to files on the public storage, we need to enclose ‘storage’ in the link.
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search