Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > BOOK: Beginning PHP 5.3
Password Reminder
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning PHP 5.3
This is the forum to discuss the Wrox book Beginning PHP 5.3 by Matt Doyle; ISBN: 978-0-470-41396-8
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning PHP 5.3 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Display Modes
  #1 (permalink)  
Old October 23rd, 2013, 04:17 PM
Registered User
Points: 5, Level: 1
Points: 5, Level: 1 Points: 5, Level: 1 Points: 5, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Oct 2013
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default I'd like some help for the upload photos

For ch9

I tried to upload a jpeg
I use win8.1

Notice: Undefined index: photo in C:\xampp\htdocs\photo\photo_upload.php on line 34
Sorry, there was a problem uploading that photo. Please contact your server administrator for help.

i typed attrib c:\<path>\..\.\photos to try to deselect read only

If someone made it work I'd really like to make it work

heres the code

<!doctype html>
<meta charset="utf-8">
<title>Process Photo Upload</title>
<link rel="stylesheet" type="text/css" href="common.css" />


if ( isset( $_POST["sendPhoto"] ) ) {
} else {

function processForm() {

if ( isset( $_FILES["photo"] ) and $_FILES["photo"]["error"] == UPLOAD_ERR_OK ) {

if ( $_FILES["photo"]["type"] != "image/jpeg" ) {
echo "<p>JPEG photos only, thanks!</p>";
} elseif ( !move_uploaded_file( $_FILES["photo"]["tmp_name"],
"photos/" . basename( $_FILES["photo"]["name"] ) ) ) {
echo "<p>Sorry, there was a problem uploading that photo.</p>" .
$_FILES["photo"]["error"] ;
} else {
} else {
switch( $_FILES["photo"]["error"] ) {
$message = "The photo is larger than the server allows.";
$message = "The photo is larger than the script allows.";
$message = "No file was uploaded. Make sure you choose a file to upload.";
$message = "PHP doesn ’ t have access to a temporary folder on the server to store the file.";
$message = "The file couldn't be written ti the server's hard disk for some reason.";
$message = "The file upload was stopped by one of the currently loaded PHP extensions.";

$message = "Please contact your server administrator for help.";
echo "<p>Sorry, there was a problem uploading that photo. $message</p>";

function displayForm() {
<h1>Uploading a Photo</h1>

<p>Please enter your name and choose a photo to upload, then click
Send Photo.</p>

<form action="photo_upload.php" method="post" enctype="multipart/

<div style="width: 30em;">
<input type="hidden" name="MAX_FILE_SIZE" value="50000" />

<label for="visitorName">Your name</label>
<input type="text" name="visitorName" id="visitorName" value="" />

<label for="photo">Your photo</label>
<input type="file" name="photo" id="photo" value="" />

<div style="clear: both;">
<input type="submit" name="sendPhoto" id="sendPhoto" value="Send Photo" />


function displayThanks() {
<h1>Thank You</h1>
<p>Thanks for uploading your photo<?php if ( $_POST["visitorName"] )
echo ", " . $_POST["visitorName"] ?>!</p>
<p>Here’s your photo:</p>
<p><img src="photo/<?php echo $_FILES["photo"]["name"] ?>" alt="Photo" /></p>
Reply With Quote

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Photo Upload form photos are not displayed shubhashish BOOK: Beginning PHP 5.3 0 July 16th, 2013 09:24 AM
How to add 5 more photos js32821 BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 5 September 3rd, 2007 12:48 PM
Ridiculus photos shapira BOOK: Professional Crystal Reports for VS.NET 0 March 7th, 2005 07:11 PM
Uploading Photos microchip Classic ASP Basics 6 April 25th, 2004 10:15 AM
Photos in access kev_79 Access 1 July 24th, 2003 02:24 PM

All times are GMT -4. The time now is 02:41 PM.

Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.