Php is_uploaded_file Function

Source: Internet
Author: User

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
("= 4.0.3, PHP 5" in PHP 4)

Is_uploaded_file-Indicates whether to upload the file through HTTP

Description
Boolean is_uploaded_file (string $ file name)
Returns TRUE if the file name is named as a post uploaded over HTTP. This is very useful to help ensure that malicious users are not trying to fool scripts to archive the work on which they should not work-for example, the/etc/passwd file.

Such a check is especially important. If there is any chance that files uploaded for anything can reveal their content to users, or even to other users on the same system.

Function is_uploaded_file () the variable $ _ FILES ['userfile'] ['tmp_name '] will upload the client variable of the file with the-name $ _ FILES ['userfile'] ['name'] does not work.

Parameters

File Name
The file name being checked.


Return Value
Returns TRUE or FALSE.

Instance

Example #1 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']. "'.";
}

?>


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.