Page 1 of 1

glob can't find the images in automatic image gallery

Posted: Fri May 20, 2011 8:13 am
by Robbedoesie
Hello,
i have just started with the tutorial automatic image gallery part one. I am this far now.
<?php 
if (is_dir('./fotoalbum/thumbs')===false){
	mkdir('./fotoalbum/thumbs',0744);
}

$images = glob('*.{jpg,jpeg,png,gif}',GLOB_BRACE);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>fotogallery</title>
<style type="text/css">
a, img {float:left; }
</style>
</head>
<body>
	<div>
<?php 
print_r($images);
?>
	</div>
</body>
</html>
But the script gives an empty array back, Array().
When i chance the image variable in
$images = glob('*.*');

it gives the php files back, Array([0]=>fotogallery.php[1]=>phpinfo.php), but no images.
What am i do wrong?

Re: glob can't find the images in automatic image gallery

Posted: Fri May 20, 2011 9:08 am
by jacek
Do you have any image files in the folder ?

Re: glob can't find the images in automatic image gallery

Posted: Fri May 20, 2011 11:44 am
by Robbedoesie
I'll have a folder fotoalbum in the same directory as the tutorial script. In there are all the image files.

Re: glob can't find the images in automatic image gallery

Posted: Fri May 20, 2011 12:19 pm
by Robbedoesie
I'll see what the solution is. I read the post by nailyener better then the first three times and find your answer. Simply a $dir does the trick. Thanks.
Sorry for this topic.

Re: glob can't find the images in automatic image gallery

Posted: Fri May 20, 2011 3:09 pm
by jacek
The way I did this was that it would be placed in the same folder as the images. At least you fixed it ;)