In PHP, "$_FILES" is a predefined array variable used to obtain file data uploaded to the server through POST. If uploading a single file, "$_FILES" is a two-dimensional array; if uploading multiple files, "$_FILES" is a three-dimensional array.
The operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
In php, "$_FILES" is a Predefined array variables.
Predefined variables are also called superglobal variables. They can be used in all scopes without being declared in advance. Through these predefined variables, you can obtain information such as user session, user operating system environment and local operating system environment.
$_FILES
The file data uploaded to the server through POST can be obtained;
If a single file is uploaded, then $_FILES is a two-dimensional array; if For multiple file uploads, $_FILES is a three-dimensional array.
Example:
Create a file.html demo upload file, the code is as follows:
<html> <head></head> <body></body> <form enctype="multipart/form-data" action="file.php" method="POST"> Send this file: <input name="userfile" type="file" /> <input type="submit" value="Send File" /> </form> </html>
Create a new PHP for receiving file information File file.php, the code is as follows:
<?php echo "<pre class="brush:php;toolbar:false">"; print_r($_FILES); ?>
After selecting the file on the file.html page, click the Send File button, the following information will be output on the page:
Array ( [userfile] => Array ( [name] => Screen Shot 2016-05-12 at 18.13.24.png [type] => image/png [tmp_name] => /private/var/tmp/phplVHp3W [error] => 0 [size] => 344925 ) )
Recommended learning: "PHP video tutorial》
The above is the detailed content of What does $_FILES mean in php. For more information, please follow other related articles on the PHP Chinese website!