Home  >  Article  >  Backend Development  >  php $_FILES detailed explanation $_FILES

php $_FILES detailed explanation $_FILES

巴扎黑
巴扎黑Original
2016-11-23 11:18:009068browse

php $_FILES Detailed explanation of $_FILES
Variables submitted to the script via HTTP POST file upload. Similar to the old $HTTP_POST_FILES array (still valid, but deprecated). See POST method upload for details.

$_FILES array content is as follows:

66b118d02f91dfe849bbdbe68241685c

$_FILES['userfile']['name']

The original name of the client machine file.

$_FILES['userfile']['type']
The MIME type of the file, which requires the browser to provide support for this information, such as "image/gif".

$_FILES['userfile']['size']
The size of the uploaded file, in bytes.

$_FILES['userfile']['tmp_name']
The temporary file name stored on the server after the file is uploaded.

$_FILES['userfile']['error']
Error code related to the file upload. ['error'] was added in PHP 4.2.0.
Note: Before PHP 4.1.0, the name of this array was $HTTP_POST_FILES, which is not an automatic global variable like $_FILES. PHP 3 does not support the $HTTP_POST_FILES array.
move_uploaded_file -- Move the uploaded file to a new location
Description
bool move_uploaded_file (string filename, string destination)


This function checks and ensures that the file specified by filename is a legal uploaded file (i.e. uploaded via PHP's HTTP POST uploaded by the mechanism). If the file is legal, it is moved to the file specified by destination.

If filename is not a legal uploaded file, no operation will occur and move_uploaded_file() will return FALSE.

If filename is a valid uploaded file but cannot be moved for some reason, no action will occur and move_uploaded_file() will return FALSE. A warning is also issued.

This kind of check is particularly important, if the uploaded file may cause its content to be displayed to the user or other users of this system


PHP single file upload





单文件上传

0){ move_uploaded_file($fileinfo['tmp_name'],$fileinfo['name']); echo '上传成功'; }else{ echo '文件太大或未知'; } } ?>

php, $_FILES detailed explanation, $_FILES php $_FILES Detailed explanation $_FILES

Statement:
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
Previous article:php object serializationNext article:php object serialization