NYCPHP Meetup

NYPHP.org

[nycphp-talk] $_FILES and form reloading

Timothy Boyden tboyden at supercoups.com
Sun Nov 12 08:37:20 EST 2006


Michael,

An approach I use which would eliminate this issue would be to use
JavaScript and do error checking as the user is still filling out the form.
The way I see it is, why make the user wait until s/he has filled out the
entire form and submitted it before telling them they made an error? Make
use of the event handlers and when they "change focus" or click on another
form field, fire off a JavaScript that checks the previous field for errors
and pop-up a dialog box that lets them know they made an error on the
previous field. A site that gives some good recommendations is here:

http://www.xs4all.nl/~sbpoley/webmatters/formval.html

As others have stated, saving the upload file to a temp file on the server
is also a possibility, but I've also in the past returned the form all
filled out with the previously submitted data (read only), with the field in
error highlighted and a message that the user will need to re-upload the
file(s). YMMV.

Cheers,


---------------------------
Timothy Boyden 
Network Administrator
tboyden at supercoups.com
  
SuperCoups® | 350 Revolutionary Drive | E. Taunton, MA 02718
508-977-2034  | www.supercoups.com
---------------------------
Local Coupons. Super Savings.®


> From: Michael Southwell <michael.southwell at nyphp.org>
> Reply-To: NYPHP Talk <talk at lists.nyphp.org>
> Date: Sat, 11 Nov 2006 11:00:18 -0500
> To: <talk at lists.nyphp.org>
> Subject: [nycphp-talk] $_FILES and form reloading
> 
> I have run into a problem with the $_FILES global and reloading a
> form when the user has omitted required information. Reloading the
> $_POST variables is no problem. But the form among other things
> offers the user a chance to upload a photo, and it is reloading that
> $_FILE information where I'm not succeeding. The relevant code is this:
> 
> <input name="photo1" type="file" class="style1" value="<?=
> $_FILES['photo1']['name'] ?>" />
> 
> print_r( $_FILES ) shows that $_FILES['photo1']['name'] exists, but
> it's not being shown in the input field.  What am I doing wrong?
> 
> Further than that, the name that exists is not fully qualified, so
> even if it were being displayed, I presume it wouldn't do any good
> upon the eventual successful submission of the form. How can I solve that?
> 
> By the way, it all works perfectly when the form doesn't need to be reloaded.
> 
> 
> Michael Southwell, Vice President for Education
> New York PHP
> http://www.nyphp.com/training - In-depth PHP Training Courses
> 
> _______________________________________________
> New York PHP Community Talk Mailing List
> http://lists.nyphp.org/mailman/listinfo/talk
> 
> NYPHPCon 2006 Presentations Online
> http://www.nyphpcon.com
> 
> Show Your Participation in New York PHP
> http://www.nyphp.org/show_participation.php




More information about the talk mailing list