File Upload 1

So what is File Upload and how does it work? File Upload or http upload allows your visitors to send files to your web server using standard forms. In the same way that there are form elements that allow you to enter text and others that allow you to choose items from a list there is a form element that allows you to choose a file.

So what does a File Upload form element look like? Well here's a small and non-functional form for you to play with. Alternatively for a working version check out our example web site...



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 the great advantage of http upload is that (as much as can be said for anything on the web) upload facilities are pretty much standard on any browser that will come to your web site.

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

<form method="post" action="file-upload-1.htm" name="submit" enctype="multipart/form-data">
  <input type="file" name="fileField"><br /><br />
  <input type="submit" name="submit" value="Submit">
</form>

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

What is 'multipart/form-data'? It's an internet standard for sending lots of different types of information over the internet as one bundle. However it doesn't really make much difference what it is because we're only interested in getting the file back out. Tell me how to get the file out of the File Upload ...