In this recipe, we are going to create an HTML form with a field of type file, which lets the user pick one or more files to upload to a server via a form submission. Perform the following steps:
- Create upload-file.html inside the templates directory, as follows:
$ mkdir templates && cd templates && touch upload-file.html
- Copy the following content to upload-file.html:
<html> <head> <meta charset="utf-8"> <title>File Upload</title> </head> <body> <form action="/upload" method="post" enctype="multipart/ form-data"> <label for="file">File:</label> <input type="file" name="file" id="file"> <input type="submit" name="submit" value="Submit"> </form> </body></html>
In the preceding template, we defined a field of type file along ...