is_uploaded_file
is used to check whether a file is uploaded through HTTP POST or not. This ensures that a malicious user cannot run scripts through files and compromise the security of a system. The general syntax for the function is as follows:
is_uploaded_file(string $filename): bool
The is_uploaded_file
function has one compulsory parameter, which is the name of the file you wish to check.
The is_uploaded_file
function returns TRUE
if the file is uploaded through HTTP POST. Otherwise, it returns false
.
The following example will help you understand the is_uploaded_file
function better. As shown, we check whether the file main.txt
has been uploaded through HTTP POST. It returns false in this case as no such file exists.
<?php$file = "main.txt";if (is_uploaded_file($file))echo ("file is uploaded through HTTP POST");elseecho ("file is not uploaded through HTTP POST");?>
Free Resources