Home  >  Article  >  Backend Development  >  php is_uploaded_file function_PHP tutorial

php is_uploaded_file function_PHP tutorial

WBOY
WBOYOriginal
2016-07-20 11:01:001469browse

The function of is_uploaded_file in php is to determine whether the uploaded file is successful. ​

The function of is_uploaded_file in php is to determine whether the uploaded file is successful.

is_uploaded_file
(PHP 4" = 4.0.3, PHP 5)

is_uploaded_file - tells whether to upload the file via HTTP

Description
boolean is_uploaded_file (string $filename)
Returns TRUE if the file filename is named uploaded via HTTP. This is useful to help ensure that a malicious user is not trying to trick the script into working with a file that shouldn't work - for example, /etc/passwd.

Such checks are particularly important as there is any chance that anything the uploaded files could reveal their contents to the user, or even to other users on the same system.

To work properly, function is_uploaded_file() requires arguments like variables $_FILES['userfile']['tmp_name'] which will be the name of the uploaded file - client variables $_FILES['userfile']['name'] are not Not working.

Parameters

File name
The name of the file being checked.


Return value
Returns TRUE or FALSE on success or failure.

Example

Example #1 Example of is_uploaded_file ( )

if (is_uploaded_file($_FILES['userfile']['tmp_name'])) {
echo "File ". $_FILES['userfile']['name'] ." uploaded successfully.n";
echo "Displaying contentsn";
Readfile($_FILES['userfile']['tmp_name']);
} else {
echo "Possible file upload attack: ";
echo "filename '". $_FILES['userfile']['tmp_name'] . "'.";
}

?>


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/445471.htmlTechArticleThe function of is_uploaded_file in php is to determine whether the uploaded file is successful. The function of is_uploaded_file in php is to determine whether the uploaded file is successful. is_uploaded_file (in PHP 4...
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