Jump to content
Larry Ullman's Book Forums

Recommended Posts

I am having a problem when I click on the link that this script creates. My structure is D://xampp/uploads (This is where the images have been uploaded to) My main files are in D://xampp/htdocs/tuition.


When I publish the script in the browser it sees the images in the table I.E.:


Image Name  -  Image Size

basketball.jpg       154kb  

penguins.jpg           89kb  


I have checked and double checked the code. I have also tried replacing line 46 from $dir = '../../uploads'; // Define the directory to view. to $dir = 'D://xampp/uploads'; // Define the directory to view. But i still get the same error:


The page code is:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
	<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
	<script language="JavaScript">
	<!-- // Hide from old browsers.
	// Make a pop-up window function:
	function create_window (image, width, height) {
		// Add some pixels to the width and height:
		width = width + 10;
		height = height + 10;
		// If the window is already open, 
		// resize it to the new dimensions:
		if (window.popup && !window.popup.closed) {
			window.popup.resizeTo(width, height);
		// Set the window properties:
		var specs = "location=no, scrollbars=no, menubars=no, toolbars=no, resizable=yes, left=0, top=0, width=" + width + ", height=" + height;
		// Set the URL:
		var url = "show_image.php?image=" + image;
		// Create the pop-up window:
		popup = window.open(url, "ImageWindow", specs);
	} // End of function.
<p>Click on an image to view it in a separate window.</p>
<table align="center" cellspacing="5" cellpadding="5" border="1">
		<td align="center"><b>Image Name</b></td>
		<td align="center"><b>Image Size</b></td>
<?php # Script 10.4 - images.php
// This script lists the images in the uploads directory.

$dir = '../../uploads'; // Define the directory to view.

$files = scandir($dir); // Read all the images into an array.

// Display each image caption as a link to the JavaScript function:
foreach ($files as $image) {

	if (substr($image, 0, 1) != '.') { // Ignore anything starting with a period.
		// Get the image's size in pixels:
		$image_size = getimagesize ("$dir/$image");
		// Calculate the image's size in kilobytes:
		$file_size = round ( (filesize ("$dir/$image")) / 1024) . "kb";
		// Make the image's name URL-safe:
		$image = urlencode($image);
		// Print the information:
		echo "\t<tr>
\t\t<td><a href=\"javascript:create_window('$image',$image_size[0],$image_size[1])\">$image</a></td>
	} // End of the IF.
} // End of the foreach loop.

However when I click in the link to show the image in a popup window I get the error:


Object not found!

The requested URL was not found on this server. The link on the referring page seems to be wrong or outdated. Please inform the author of that page about the error.

If you think this is a server error, please contact the webmaster.

Error 404 localhost
Apache/2.4.7 (Win32) OpenSSL/1.0.1e PHP/5.5.9
Link to comment
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.
Note: Your post will require moderator approval before it will be visible.

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.


  • Create New...