Clenons shitty website

 

Adding media from a folder to website using php

To create my art and high voltage pages I want to drop the videos into one folder and instantly display them on the website. For that you have to create a script that creates the html code for you. I chose php for that.

Source: https://stackoverflow.com/questions/33588691/put-all-images-from-directory-into-html

This is the script I thew together from googling a bunch

I'm using this for images:

      <?php

          $files = scandir('path/to/directory');

          foreach($files as $file) {

              if($file !== "." && $file !== "..") {

                  echo "<a style='padding:7px' target='_blank' href='path/to/directory/$file'><img src='source/art/$file' width=10% ></a>";

              }

          }

      ?>

And this for videos:

    <?php

      $files = scandir('path/to/directory');

      foreach($files as $file) {

        if($file !== "." && $file !== "..") {

          echo "<video controls width='20%'><source src='path/to/directory/$file' type='video/mp4'></video>";

        }

      }

    ?>