Wrox Programmer Forums
|
BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5
This is the forum to discuss the Wrox book Beginning PHP4 by Wankyu Choi, Allan Kent, Chris Lea, Ganesh Prasad, Chris Ullman; ISBN: 9780764543647
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 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 February 23rd, 2004, 01:47 PM
Authorized User
 
Join Date: Sep 2003
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default input file...

boys:-)....i have a problem. I have created a form but I don't know a metod to put a default value in a input file with php..

it's possible?

(excuse me for my english:-))

joeore

 
Old February 23rd, 2004, 07:15 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 836
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Depends on the type of input field. For the most part, you can simply set the value attribute of an input field:

<input type="text" name="firstName" value="Nikolai" />
<input type="hidden" name="id" value="5" />

For radio buttons, you already set the value of each radio. To make sure one of them is checked, use the checked attribute:

<input type="radio" name="gender" value="m" checked="true" />
<input type="radio" name="gender" value="f" />

For dropdown lists, you can preselect one (or more, if your dropdown is multiple) options by using the selected attribute:

<select name="languages" multiple="yes">
<option value="English" selected="true">English</option>
<option value="Spanish" selected="true">Spanish</option>
<option value="French">French</option>
<option value="Greek" selected="true">Greek</option>
</select>


Now that you know the HTML required to pre-populate form fields, it shouldn't be too difficult to write the PHP to generate this.


Take care,

Nik
http://www.bigaction.org/
 
Old February 23rd, 2004, 07:58 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 836
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Actually, (and I'm sorry because I'm not feeling well!!) I just realized after rereading your original post that you're not interested in prepopulating just ANY form input field, but one of type "file".

The file input type also includes a value attribute, but it's not supported by most browsers. I guess you're out of luck, unless it can be done with javascript. I tried, but couldn't get it to work.

I suppose that this is a GOOD THING, since you really wouldn't want some website to be able to use javascript to pre-populate a file input field.

Imagine if it that was supported -- you could visit a web page that pre-populated a file upload form with a password file. Javascript can automatically submit the form to the server. The server can then begin a brute-force attack on your password file and crack all your system passwords.


Maybe it's better that you can't prepopulate a file input field...


Take care,

Nik
http://www.bigaction.org/





Similar Threads
Thread Thread Starter Forum Replies Last Post
how can i get input of file through servlet? myhrvod Servlets 1 March 26th, 2007 01:46 AM
How do I validate file input? grstad Classic ASP Professional 1 February 18th, 2007 08:45 PM
No input file specified stephen_c_ Beginning PHP 3 January 27th, 2006 10:00 PM
Any File (input #1) experts help? enterbase Access VBA 2 February 2nd, 2004 08:35 AM
Multiple file input single file output.... jdm_mboy Biztalk 1 July 2nd, 2003 03:35 AM





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