Roots
Back

Form Upload Fields

How do they work?

This tutorial will explain the HTML side of uploading files to a server; it is useless without knowledge of some kind of scripting language however. You can read a tutorial on using PHP to manage file uploads to fully understand the process and how to use it.

An upload field in a form will provide a user with a field to write the full address of a file on their system in, as well as a 'Browse' button to search for and select a file.

How to create upload fields

<input type="hidden" name="MAX_FILE_SIZE" value="number">
<input type="file" name="text">

number - The maximum number of bytes that a file can be. This is not implemented by a lot of browsers, and you should not rely on it to prevent large file uploads. You can do this more effectively with PHP.
name - The unique name to identify this file upload field.

For example;

<form action="form-process.php" method="get">
<input type="hidden" name="MAX_FILE_SIZE" value="1500">
<input type="file" name="file">
<input type="submit" value="Submit">
</form>