We start formal learning and learn how to upload files. To upload files, a form must be prepared on the web page.
This is a simple HTML page form. The form form prepares a dedicated class for file content. When type=file is selected, the default is to upload the file content.
Let’s take a look at the code and precautions of the form
<html> <head> <meta charset="utf-8" /> <title>单文件上传</title> </head> <body> <form action="file.php" method="post" enctype="multipart/form-data"> <input type="file" name="file"> <input type="submit" value="上传"> </form> </body> </html>
Notes:
1. The parameter method in the form form must be post. If it is get, file upload cannot be performed
2.enctype must be multipart/form-data