I am a beginner in PHP coding. I try to create a page using $_FILES under XAMPP localhost environment. PHP is 7.2.7 version. The problem is that, when I click the submit button to upload the file, nothing happens. (I use a "if...else" loop to see if all conditions not happen, and the result is nothing happen.)
HTML:
<form action="upload.php" method="POST" enctype="multipart/form-data">
<label for="file">File upload:</label>
<input type="file" name="User Name">
<br><br>
<input type="submit">
<br><br>
</form>
PHP:
if(isset($_POST['submit'])){
if ($_FILES["file"]["error"] > 0)
{
echo "Error: " . $_FILES["file"]["error"] . "<br />";
}
else
{
echo "Upload: " . $_FILES["file"]["name"] . "<br />";
echo "Type: " . $_FILES["file"]["type"] . "<br />";
echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
echo "Stored in: " . $_FILES["file"] ["tmp_name"];
}
}
else {
echo "nothing";
}