One, the form of forgetting to add enctype= "Multipart/form-data"
When we learn HTML, we all know that form is the most common way to submit data to the server, and there will be file uploads when many data are submitted. Of course, file stream upload requires some special processing.
<form action="" method="post" enctype="multipart/form-data">
......
</form>
Why add enctype= "Multipart/form-data"? Here's a look at the explanation for the Enctype attribute in the form
value |
Description |
application/x-www-form-urlencoded |
Encode all characters before sending (default) |
Multipart/form-data |
Character encoding is not. You must use this value when you use a form that contains a file upload control. |
Text/plain |
Spaces are converted to "+" plus signs, but special characters are not encoded. |
So you must add multipart/form-data when uploading files
Second, in the php.ini must open the File_uploads=on
The purpose of this option is to configure whether to allow files to be uploaded. If set to OFF, the file is not allowed to be uploaded, so the $_files value cannot be received, so the file upload must be turned on.
This parameter is in the PHP config file php.ini
There is no problem with the form in PHP, but $_files is an empty solution