PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
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.
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;
}
Last edited by db579 on Sun Jul 18, 2010 7:23 pm, edited 1 time in total.
while (! == ($file = readdir($handle))) {
$file =$dir.$file;
// Check whether the item is a valid file
if (is_file($file)){
But it still doesn't work. This part does work if I add $dir.$file into the is_file statement itself instead though which is why I'm very confused by this but doing it that way is causing me problems further on. What am I doing wrong? Thanks again
if you want to address a file that is not located in the same folder than the php script executed, you need to specify the folder as well. if this causes you further troubles, you need to revise your code.