Start out by creating a one-field form. You can create a form to upload as many files as you like, after you get this sequence to work with one file.
Open a new file in your text editor and type the following HTML:
<HTML> <HEAD> <TITLE>Upload a File</TITLE> </HEAD> <BODY> <H1>Upload a File</H1>
Begin your form. Assume that the method is POST and the action is a script called do_upload.php. Because you'll be sending more than just text, use the ENCTYPE attribute.
<FORM METHOD="POST" ACTION=" do_upload.php" ENCTYPE="multipart/form-data">
Create an input field for the file with a text label. Assume that you'll be uploading an image file, and name the input field img1:
| Note |
The TYPE="file" attribute in the form field will display an input field with a Browse button. The Browse button launches a file manager through which you select the file to upload. |
Add a submit button, and then close your form and add some more HTML so that the document is valid:
<P><INPUT TYPE="submit" NAME="submit" VALUE="Upload File"></P> </FORM> </BODY> </HTML>
Save the file with the name upload_form.html, and place this file in the document root of your web server.
Open your web browser and type http://127.0.0.1/upload_form.html.
In the next section, you create the script that handles the file upload.