Wrox Programmer Forums
|
BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0
This is the forum to discuss the Wrox book Beginning PHP5, Apache, and MySQL Web Development by Elizabeth Naramore, Jason Gerner, Yann Le Scouarnec, Jeremy Stolz, Michael K. Glass; ISBN: 9780764579660
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 24th, 2005, 08:46 PM
Authorized User
 
Join Date: Aug 2005
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter 7 file upload problems

I am having trouble with Chapter 7, page 197 of the PHP5 book with getting file upload to work with the code in "upload_image.php" which provides interface to browse for your file to upload:

The code:
---------------------------------------------------------------
<form name="form1" method = "post" action="check_image.php"
    enctype="multipart/form-data>
<table ... etc

etc...

<tr>
<td><input name="image_filename" type="file" d="image_filename"></td>
</tr>
<tr>
<td><input type="submit" name="Submit" value="Submit">
---------------------------------------------------------------------

I run this code and the form appears OK in the Browser. Then enter the data and browse for the file to upload, and then click Submit to run "check_image.php".

All the $_POST data is passed except for the file_name so the code fails with a bunch of error messages.

I have tried for days to get this to work and began to wonder if there were something wrong in my configuration.

I searched for clues in forums and code snippets. I found a set of code at http://px.sklar.com/
"PX: the PHP code exchange" called "Easy PHP Upload 2.24 by Olaf" which uses class functions.

The download for this is at http://px.sklar.com/section.html?id=14.

This uses "enctype="multipart/form-data" file browser and all the $_POST variables are passed so the code works (after I modified it to fit my directories). So I must be configured properly.

I am using PHP 5.04, Apache 2.0.54 for Windows XP. Also MySQL.

Any ideas why this won't work would be appreciated.
 
Old August 27th, 2005, 02:29 PM
Authorized User
 
Join Date: Aug 2005
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Oops! I found the answer to my problem. I did not copy a line of code properly from the book.

I typed:
$image_tempname = $_POST['image_filename'];

and it should have been :
$image_tempname = $_FILES['image_filename'];

Dumb mistake!





Similar Threads
Thread Thread Starter Forum Replies Last Post
Filter File Types in ASP.NET File Upload ramuis78 ASP.NET 2.0 Basics 2 May 31st, 2007 10:50 AM
Problems regarding upload functionality jacob Javascript 1 January 2nd, 2007 06:38 AM
asp file upload script having problems with MYSQL paulmcn Classic ASP Databases 0 September 16th, 2005 01:26 PM
Whole Folder upload(Multi file Upload) ramasamy_rams XML 1 September 9th, 2005 12:43 PM
File upload problems in PHP 4.3.2 clem_c_rock Pro PHP 2 November 1st, 2004 10:49 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.