glob can't find the images in automatic image gallery

Post here is you are having problems with any of the tutorials.
Post Reply
User avatar
Robbedoesie
Posts: 97
Joined: Thu May 19, 2011 7:37 pm
Location: Enkhuizen, Holland

glob can't find the images in automatic image gallery

Post 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?
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

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

Post by jacek »

Do you have any image files in the folder ?
Image
User avatar
Robbedoesie
Posts: 97
Joined: Thu May 19, 2011 7:37 pm
Location: Enkhuizen, Holland

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

Post by Robbedoesie »

I'll have a folder fotoalbum in the same directory as the tutorial script. In there are all the image files.
User avatar
Robbedoesie
Posts: 97
Joined: Thu May 19, 2011 7:37 pm
Location: Enkhuizen, Holland

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

Post 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.
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

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

Post 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 ;)
Image
Post Reply