I have a simple file base on my webpage, let's say ProjectFolder
is the main folder, which contains completely all files.
The folder I want to access goes like this:
ProjectFolder/Movies/Movie1/cover/Movie1.jpg
ProjectFolder/Movies/Movie1/movie/Movie1.mp4
ProjectFolder/Movies/Movie2/cover/Movie2.jpg
ProjectFolder/Movies/Movie2/movie/Movie2.mp4
ProjectFolder/Movies/Movie3/cover/Movie3.jpg
ProjectFolder/Movies/Movie3/movie/Movie3.mp4
And so on... Movie 1,2,3,4... etc folders can be uploaded manually, so I have to be able to show all of them, no matter the count (they are also with various names, Movie1,2,3 is just for example)
Using php
, I made a loop that goes through all subfolders of the ProjectFolder/Movie
folder and for each one of them, creates a portion of html code, in which I need to use:
This is my php:
$i = 1;
$path = "./Movies";
$dir = new DirectoryIterator($path);
foreach ($dir as $fileinfo)
{
if ($fileinfo->isDir() && !$fileinfo->isDot())
{
//(html code)
}
}
What php code should I replace the html "" parts from 1, 2 and 3?
<?php
$dir = './Movies';
$directories = array();
$files_list = array();
$files = scandir($dir);
foreach ($files as $file)
{
if (($file != '.') && ($file != '..'))
{
if (is_dir($dir.'/'.$file))
{
$directories[] = $file;
}
}
}
foreach ($directories as $directory)
{
?>
HTML code....
<?php echo "Movies/"; echo $directory; echo "/movie/"; echo $directory; echo ".mp4"; ?>
Same for ".jpg" and the button code looks like this:
<div>
<form action="<?php echo "http://blabla.com/"; echo $directory; echo ".php"; ?>">
<input type="submit" class="button" value="GO TO <?php echo $directory; ?>">
</form>
</div>