elgato454
-
Posts
10 -
Joined
-
Last visited
Posts posted by elgato454
-
-
I can confirm that I have a C:\xampp\htdocs\phpmysql\php-work\ch11\uploads\unavailable.png file. I don't have a show_image.php file, however. Maybe that's where we're going wrong.
-
-
So I managed to follow the steps outlined in that last post and came up with this URL:
http://localhost/phpmysql/php-work/ch11/show_image.php?image=unavailable.png
-
I went and reconfigured the httpd.conf file as per Appendix A. I still got nowhere.
Keep in mind that I am EXTREMELY new to this. I probably forgot to mention this in my earlier posts.
-
For Script 11.2, the URL is this:
http://localhost/phpmysql/php-work/ch11/upload-image.php
For Script 11.3, the URL is:
http://localhost/phpmysql/php-work/ch11/function.js
For Script 11.4, this is the URL:
http://localhost/phpmysql/php-work/ch11/images.php
Hope that helps.
-
The root folder is this:
C:\xampp\htdocs
Originally, I had my temporary files stored in the default folder; but, like I said, I set two temp file folders up inside my directory. The first one is:
C:\xampp\htdocs\phpmysql\php-work\uploads
The second one is the one I have listed in the previous post:
C:\xampp\htdocs\phpmysql\php-work\ch11\uploads
I keep going back and forth between folders and, for some reason, I'm still not getting the picture to display.
Does this help?
-
This is the directory in which the pictures are in:
C:\xampp\htdocs\phpmysql\php-work\ch11\uploads
Of course, I've changed the directory three times and I'm still getting the error message instead of the pictures I uploaded.
-
This is my error message:
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.
-
Good Afternoon!
I'm having trouble executing Script 11.4 in Chapter 11. The code for Script 11.2 reads:
<?php # Script 11.2 - upload-image.php// Check if the form has been submitted:if ($_SERVER['REQUEST_METHOD'] == 'POST') {// Check for an uploaded file:if (isset($_FILES['upload'])) {// Validate the type. Should be JPEG or PNG.$allowed = array ('image/pjpeg', 'image/jpeg', 'image/JPG','image/X-PNG', 'image/PNG', 'image/png', 'image/x-png');if (in_array($_FILES['upload']['type'], $allowed)) {// Move the file over.if(move_uploaded_file($_FILES['upload']['tmp_name'], "../uploads/{$_FILES['upload']['name']}")) {echo '<p><em>The file has been uploaded!</em></p>';} // End of move IF.else {// Invalid typeecho '<p class="error">Please upload a JPEG or PNG image.</p>';}} // End of isset($_FILES['upload'] IF.// Check for an error:if ($_FILES['upload']['error'] > 0) {echo '<p class="error">The file could not be uploaded because: <strong>';// Print a message based upon the error.switch($_FILES['upload']['error']) {case 1:print 'The file exceeds the upload_max_file size setting in php.ini.';break;case 2:print 'The file exceeds the MAX_FILE_SIZE setting in the HTML form.';break;case 3:print 'The file was only partially uploaded.';break;case 4:print 'No file was uploaded.';break;case 6:print 'No temporary folder was available.';break;case 7:print 'Unable to write to the disk.';break;case 8:print 'File upload stopped.';break;default:print 'A system error occured.';break;} // End of error IF.// Delete the file as if it still exists:if (file_exists($_FILES['upload']['tmp_name']) && is_file($_FILES['upload']['tmp_name']) ){uplink($_FILES['upload']['tmp_name']);}} // End of the submitted conditional}}?>This is my Script 11.3: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 propertiesvar 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 popup window:popup = window.open(url, "ImageWindow", specs);popup.focus();}Finally, this is Script 11.4:<?php # Script 11.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");// Make the image's name URL-safe:$image_name = urlencode($image);// Print the information:echo "<li><a href=\"javascript:create_window('$image_name',$image_size[0],$image_size[1])\">$image</a></li>\n";} // End of the IF.} // End of the foreach loop.?>The problem is, when I click on any of the image links in Script 11.4, it shows a "Error 404 - File Not Found" message instead of the picture itself. It also says something about the directory being "wrong or outdated". I have not been able to fix this error, regardless of what I do.Could you give me any pointers as to what might be wrong? Thanks!
Script 11.4 - Error 404 Upon Opening New Window
in PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (4th Edition)
Posted
After working on the show_image.php code, I got everything working.
LESSON LEARNED: Finish each chapter BEFORE testing your code. Period.