Apr 21, 2019 02:27 PM
(This post was last modified: Apr 21, 2019 02:56 PM by Babadook.)
I need this code set to where it starts from the root directory of my site. I use this both locally and externally so I need it to work for both.
I've tried all of these:
What works:
However, I can't use this as the file is used in multiple directories with differing lengths from the root.
I can set it to use the files in the local directory just fine. But I can't get it above the directory. When I do this with $dir it breaks the image and doesn't display "Temporary.jpg" while trying to grab "mysite.com/var/www/html/uploads/Photos/MovieCovers/5th%20Passenger%20(2018)@2x.jpg". $dir2 and everything else shows temporary image and
Specific line i want pointed to '/uploads/Photos/MovieCovers/*.{jpeg,jpg,png,gif}':
Full Code:
I've tried all of these:
PHP Code
<?php
$dir = $_SERVER['DOCUMENT_ROOT'];
$dir2 = $_SERVER['HTTP_HOST'];
/uploads/Photos/MovieCovers/*.{jpeg,jpg,png,gif}
./uploads/Photos/MovieCovers/*.{jpeg,jpg,png,gif}
../uploads/Photos/MovieCovers/*.{jpeg,jpg,png,gif}
What works:
PHP Code
<?php
$images = glob('../../../../uploads/Photos/MovieCovers/*.{jpeg,jpg,png,gif}', GLOB_BRACE);
However, I can't use this as the file is used in multiple directories with differing lengths from the root.
I can set it to use the files in the local directory just fine. But I can't get it above the directory. When I do this with $dir it breaks the image and doesn't display "Temporary.jpg" while trying to grab "mysite.com/var/www/html/uploads/Photos/MovieCovers/5th%20Passenger%20(2018)@2x.jpg". $dir2 and everything else shows temporary image and
Specific line i want pointed to '/uploads/Photos/MovieCovers/*.{jpeg,jpg,png,gif}':
PHP Code
<?php
$images = glob($dir . "/uploads/Photos/MovieCovers/*.{jpeg,jpg,png,gif}", GLOB_BRACE);
Full Code:
PHP Code
<?php
$dir = $_SERVER['DOCUMENT_ROOT'];
$temp = '/images/Temporary.jpg';
$movies = glob('./*.{mp4,m4v}', GLOB_BRACE);
$images = glob($dir . "/uploads/Photos/MovieCovers/*.{jpeg,jpg,png,gif}", GLOB_BRACE);
$subtitles = glob('./*.{srt}', GLOB_BRACE); #To be used later.
echo file_get_contents($dir . "/html/header.html");
foreach ($images as $image) {
$lookup[pathinfo($image, PATHINFO_FILENAME)] = $image;
}
foreach ($movies as $movie) {
$image = $lookup[pathinfo($movie, PATHINFO_FILENAME)] ?? $temp;
echo '<a href="' . $movie . '">
<img src="' . $image . '" style="width:300px;height:350px;border:0;">
</a>';
}
echo file_get_contents($dir . "/html/footer.html");
?>
I collect tutorials/methods. I enjoy learning the methods more than using them. Feel free to DM them to me!
I often forget HF exists, I check in every now and then.
I often forget HF exists, I check in every now and then.


