There is no problem with the form in PHP, but $_files is an empty solution

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.