Jump to content

imagegallery doesn't work


wesley

Recommended Posts

Hello.

 

I have a php script and this show the images from a folder img in the browser. But the images doesn't show in the browser.

Can someone help me with the code?

 

My question is: what is wrong on the script? How can I show the images in the browser?

 

thanks in advance.

 

my code is:

<?phpfunction showGallery(){	$galleryHTML .= "<ul>";	$images = new DirectoryIterator("img");	while($images -> valid() ){	$file = $images->current();	$filename = $file->getFilename(); 	$src = "img/$filename";		$info = new Finfo( FILEINFO_MIME_TYPE );	$type = $info->file($src);		if($type === "image/jpeg"){		$galleryHTML .= "<li><img src='$src' alt='image gallery' /></li>";	}	$images->next();	}	$galleryHTML .= "</ul>";	return $galleryHTML;}echo showGallery();?>
Link to comment
Share on other sites

Thank you,

 

But I have add $galleryHTML =""; on the top (see code), you mean this?, and the images (all jpg) are in the img folder and it doesn't work. the images are not to see in the browser.

 

Can you help me?

<?phpfunction showGallery(){	$galleryHTML ="";	$galleryHTML .= "<ul>";	$images = new DirectoryIterator("img");	while($images->valid() ){	$file = $images->current();	$filename = $file->getFilename(); 	$src = "img/$filename";		$info = new Finfo( FILEINFO_MIME_TYPE );	$type = $info->file($src);		if($type === "image/jpg"){		$galleryHTML .= "<li><img src='$src' alt='image gallery' /></li>";	}	$images->next();	}	$galleryHTML .= "</ul>";	return $galleryHTML;}echo showGallery();?>
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...