On my website, there is a video upload section. It generates a link ending string based on random numbers and time, and then gives to the user to share. This link shows a page with their video. On the homepage I would like to show every one of the videos uploaded, but the videos are all in their seperate folders, etc: 234209346/video.mp4
I want to show this video file in a video tag, but i need it to check every subdirectory for videos and show them there, based on date. I’m very new to php, so please explain things.
Advertisement
Answer
Option 1: Best – Change your approach
When you save the videos, use a Database to save each video information. This way you will be able to quickly retrieve all the videos very quickly in your homepage.
If you don’t have Mysql installed, you can also use a .sqlite local file or even a CSV/JSON. But storing the info is much better than just looking for files at runtime
Option 2: Bad, but exactly what you requested – recursive file listing
Read here for another answer on how to do recursive file listing. The only difference is that you will need to check the files to have the correct .mp4 extension, checking the filename.