ptg16476052
340 LESSON 12: Designing Forms
Let’s look at a simple form that supports file uploads:
<form action="/upload" enctype="multipart/form-data" method="post">
<input type="file" id="new_file">
<input type="submit">
</form>
After you’ve created a form for uploading a file, you need a program that can process the
file submission. Creating such a program is beyond the scope of this book, but all popular
web programming environments support file uploads.
Using Other Form Controls
In addition to form controls you can create using the input element, there are three that
are elements in and of themselves.
Using the button Element
A button you create using the button element is similar to the buttons you create with the
input element, except that content included between the opening and closing button tags
appears on the button.
You can create three different types of buttons: Submit, Reset, and Custom. The
<button> tag is used to create buttons. As with other form fields, you can use the name
attribute to specify the name of the parameter sent to the server, and the value attribute
to indicate which value is sent to the server when the button is clicked. Unlike buttons
created with the <input> tag, the bu tton’s label is specified by the content within the
<button> tag, as shown in this code:
Input ▼
<button type="submit"><b><i>Submit button</i></b></button>
<button type="custom"><img src="recycle.gif"></button>
The button element is shown in a browser in Figure 12.17.