readdir followed by is_file
Posted: Sun Jul 18, 2010 6:37 pm
I'm trying to make use of some code for a simple photo gallery but I'm running into problems because the photos are no longer all stored in the same directory as the function script.
The script seems to run into problems at line 42 as the script is no longer stored in the same directory as the images. Full script is attached but this is the section I think I'm having problems with. Thanks very much for any help.
The script seems to run into problems at line 42 as the script is no longer stored in the same directory as the images. Full script is attached but this is the section I think I'm having problems with. Thanks very much for any help.
Code: Select all
function generateThumbnails(){
global $thmb_width,$thmb_height,$dir;
// Open the album directory
if ($handle = opendir($dir)) {
// Read all files from the album directory
while (! == ($file = readdir($handle))) {
// Check whether the item is a valid file
if (is_file($file)){
// Check whether the image is a thumbnail
if (strpos($file,'_th.jpg')){
$isThumb = true;
} else {
$isThumb = false;
}