PHP - help

Miscellaneous Forums/General Discussion/PHP - help

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Here's a working version - When I got yours to work the resizing of images didn't appear to work either :/

showgallery.php
<?php

$fCount = 0;



if ($handle = opendir('bignails')) {
    while (false !== ($file = readdir($handle))) { 
        if ($file != "." && $file != "..") {
	        if (substr($file, strlen($file)-3, 3)=="jpg" ) {
	            $fCount=$fCount+1;
				$fName[] = $file;
	        }            
        }
    }
}
closedir($handle);

?>

<br/>

<?php echo "Images in gallery: ",$fCount; ?>

<table cellspacing = "2">

	<?php for($i=0; $i<=$fCount-1; $i++){
	$Name=$fName[$i];
	?>
	<?php echo $Name; ?> 
	<td>
		<tr>
		<a href="bignails/<?php echo $Name; ?>">
		<img src="tn_gen/thumb.php?<?php echo $Name; ?>">
		</a>
		</tr>
	</td>
	<?php } ?>
	
</table>


thumb.php
<?php
header("Content-Type: image/jpeg");

$image_file = str_replace('..', '', $_SERVER['QUERY_STRING']);
$image_path = "../bignails/$image_file";

function createthumb($src_image,$new_w,$new_h)
{
	$src_img=imagecreatefromjpeg($src_image);
	$old_x=imageSX($src_img);
	$old_y=imageSY($src_img);
	if ($old_x > $old_y) 
	{
		$thumb_w=$new_w;
		$thumb_h=$old_y*($new_h/$old_x);
	}
	if ($old_x < $old_y) 
	{
		$thumb_w=$old_x*($new_w/$old_y);
		$thumb_h=$new_h;
	}
	if ($old_x == $old_y) 
	{
		$thumb_w=$new_w;
		$thumb_h=$new_h;
	}
	$dst_img=ImageCreateTrueColor($thumb_w,$thumb_h);
	imagecopyresampled($dst_img,$src_img,0,0,0,0,$thumb_w,$thumb_h,$old_x,$old_y); 
	imagejpeg($dst_img); 
	imagedestroy($dst_img); 
	imagedestroy($src_img); 
}

# Display the image
createthumb($image_path,80,80);
?>