PHP is_uploaded_file() Function
Definition and Usage
The is_uploaded_file() function determines whether the specified file is uploaded via HTTP POST.
Syntax
is_uploaded_file(file)
Parameter | Description |
---|---|
file | Required. Specifies the file to be checked. |
Description
If file Returns TRUE if the file specified is uploaded via HTTP POST.
This function can be used to ensure that malicious users cannot deceive the script to access files that cannot be accessed, such as /etc/passwd.
This check is particularly important if there is a possibility that the uploaded file may cause the content to be displayed to users or other users of this system.
Tips and Comments
Note:The result of this function will be cached. Please use clearstatcache() to clear the cache.
Example
<?php $file = "test.txt"; if(is_uploaded_file($file)) { echo("$file is uploaded via HTTP POST"); } else { echo("$file is not uploaded via HTTP POST"); } ?>
Output:
test.txt is not uploaded via HTTP POST