agiannis
6/14/2019 - 2:55 PM

Check if file is allowed to upload

label: php , server , file , test , uploading , uploaded , restrict

<!DOCTYPE html>
<html>
<body>

<form  method="post" enctype="multipart/form-data">
    Select file to upload:
    <input type="file" name="fileToUpload" id="fileToUpload">
    <input type="submit" value="Upload" name="submit">
</form>

</body>
</html>
<?php
if(isset($_POST["submit"])) {
    move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $_FILES["fileToUpload"]["name"]);
    echo "<pre>";
    var_dump($_FILES["fileToUpload"]);
    echo "</pre>";
}