PHP - help

Miscellaneous Forums/General Discussion/PHP - help

Hey,

It's still not working - I did a test with the source below..

The image is located in "Mydomain.com/ext/bignails/ss4.jpg"

The script is located in "Mydomain.com/ext/tn_gen/thumb.php" its also where the show gallery script is - which is what I call in the website

I visited "www.mydomain.com/ext/tn_gen/thumb.php?ss4.jpg" and got a little red x... (you know the image that's produced in IE if it cant find the image)

here's the current source - I think it has something to do with where the image is located relative to the locating the script does.. They're obviously not matching up.

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

define('MAX_WIDTH', 80);
define('MAX_HEIGHT', 80);


# Get image location
$image_file = str_replace('..', '', $_SERVER['QUERY_STRING']);
$image_path = "../bignails/$image_file";
echo "got location ",$image_path," file is ",$image_file;

# Load image
$img = @imagecreatefromjpeg($image_path);
echo "img created";

# If an image was successfully loaded, test the image for size
if ($img) {

    # Get image size and scale ratio
    $width = imagesx($img);
    $height = imagesy($img);
    $scale = min(MAX_WIDTH/$width, MAX_HEIGHT/$height);

    # If the image is larger than the max shrink it
    if ($scale > 1) {
        $new_width = floor($scale*$width);
        $new_height = floor($scale*$height);

        # Create a new temporary image
        $tmp_img = imagecreatetruecolor($new_width, $new_height);

        # Copy and resize old image into new image
        imagecopyresized($tmp_img, $img, 0, 0, 0, 0,
                         $new_width, $new_height, $width, $height);
        imagedestroy($img);
        $img = $tmp_img;
    }
}

# Create error image if necessary
if (!$img) {
    $img = imagecreate(MAX_WIDTH, MAX_HEIGHT);
    imagecolorallocate($img,0,0,0);
    $c = imagecolorallocate($img,70,70,70);
    imageline($img,0,0,MAX_WIDTH,MAX_HEIGHT,$c2);
    imageline($img,MAX_WIDTH,0,0,MAX_HEIGHT,$c2);
}

# Display the image
imagejpeg($img);
exit;
?>


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>


any ideas?