Jump to content
Larry Ullman's Book Forums
Sign in to follow this  

Images Not Displaying Chapter 11

Recommended Posts

My show_image.php script is not working. When I click on the links the popup window comes up but the images don't display, only the unavailable.jpg image displays. I checked the uploads folder and it seems ok. I am using the downloaded script from this site to make sure the code is ok. For images.php, and upload_image.php, and functions.js,  I am also using this site's scripts. I tried to see the source code from the popup window and there is nothing it is blank. 


Here is the show_images.php code.

<?php # Script 11.5 - show_image.php
// This page displays an image.

$name = FALSE; // Flag variable:

// Check for an image name in the URL:
if (isset($_GET['image'])) {

	// Make sure it has an image's extension:
	$ext = strtolower ( substr ($_GET['image'], -4));
	if (($ext == '.jpg') OR ($ext == 'jpeg') OR ($ext == '.png')) {

		// Full image path:
		$image = "../../../../uploads/{$_GET['image']}";

		// Check that the image exists and is a file:
		if (file_exists ($image) && (is_file($image))) {
			// Set the name as this image:
			$name = $_GET['image'];	

		} // End of file_exists() IF.

	} // End of $ext IF.
} // End of isset($_GET['image']) IF.

// If there was a problem, use the default image:
if (!$name) {
	$image = 'images/unavailable.png';	
	$name = 'unavailable.png';

// Get the image information:
$info = getimagesize($image);
$fs = filesize($image);

// Send the content information:
header ("Content-Type: {$info['mime']}\n");
header ("Content-Disposition: inline; filename=\"$name\"\n");
header ("Content-Length: $fs\n");

// Send the file:
readfile ($image);

Share this post

Link to post
Share on other sites

Could you provide some more information? PHP version? OS? Where the PHP script is (what directory)? Where the images are stored? What URL you're using?

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Create New...