Example 1 — Confirm a Genuine Upload
Assume an HTML form with a file field named photo was submitted with the POST method and enctype multipart/form-data.
<?php
if (isset($_FILES['photo']) && is_uploaded_file($_FILES['photo']['tmp_name'])) {
echo "Upload is valid", PHP_EOL;
} else {
echo "No valid upload", PHP_EOL;
} How It Works
- isset() makes sure the form really sent a field named photo.
- $_FILES['photo']['tmp_name'] holds the temporary path chosen by PHP.
- is_uploaded_file() returns true because the file came from an HTTP POST upload.
- If nothing was uploaded, the else branch prints No valid upload.

