Home > Backend Development > PHP Problem > What does $_FILES mean in php

What does $_FILES mean in php

青灯夜游
Release: 2023-03-14 10:36:01
Original
5216 people have browsed it

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.

What does $_FILES mean in php

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.

$_FILESThe 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>
Copy after login

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);
?>
Copy after login

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
    )
)
Copy after login

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!

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template