<?php
if(isset($_FILES['photo'])){
    $target_dir = "./";
    $target_file = $target_dir . basename($_FILES["photo"]["name"]);
    $imageFileType = strtolower(pathinfo($target_file, PATHINFO_EXTENSION));

    // Vérification : est-ce une vraie image ?
    $check = getimagesize($_FILES["photo"]["tmp_name"]);
    if($check !== false) {
        if (move_uploaded_file($_FILES["photo"]["tmp_name"], $target_file)) {
            echo "Le fichier a été téléchargé avec succès.";
        }
    } else {
        echo "Le fichier n'est pas une image.";
    }
}
?>

<form action="upload.php" method="post" enctype="multipart/form-data">
    Sélectionnez une image à envoyer :
    <input type="file" name="photo" id="photo">
    <input type="submit" value="Envoyer l'image" name="submit">
</form>
