Uploading Images using HTML and ASP | 2 | WebReference

Uploading Images using HTML and ASP | 2

HTML File Upload

Uploading Images using HTML and ASP

In which we discover the hidden wonders of HTML file uploads.

The HTML file upload form element is standard, but vastly underused. It allows you to create forms that can send entire files to your Web server. As a visitor it appears as just another part of just another form. You click on the file upload button to choose a file. When you submit the form the file is posted along with the rest of the form data.

Like so many useful elements of HTML, file upload was not supported in Internet Explorer 3.0 but was soon afterwards added in version 3.02. It is available in Netscape Navigator from version 2.02 onwards.

So what does it look like? Well check out the (non-functional) form below - pretty much like any other form element except that you can use the browse button to choose files.

Enter Some Text:

Choose a File:

What about the code? Well again, pretty much like any other piece of form HTML. Here's the code for the above.

<form method="post" action="photoupload.asp" name="submit" enctype="multipart/form-data">

Enter Some Text: <input type="text" name="textfield"><br><br>

Choose A File: <input type="file" name="filefield"><br><br>

<input type="submit" name="su bmit" value="submit"><br>


There are only a couple of real differences. The input type of the file upload is 'file' rather than 'text.' The 'enctype' of the form is 'multipart/form-data' - about which more of later.

Comments are welcome

Created: Aug. 19, 1999
Revised: Aug. 19, 1999

URL: http://webreference.com/dev/upload/htmlfile.html