I've been working for a while on this file uploading for php, but I can't get it to work. When I click upload the 'if' statement goes to false.
If someone could point out to me where I'm going wrong, it would be great.
<?php
$name = $_FILES["file"]["name"];
$tmp_name = $_FILES["file"]["tmp_name"];
if(isset($name)) {
if(!empty($name)) {
$location = "uploads/";
if(move_uploaded_file($tmp_name, $location . $name)) {
echo "Uploaded";
} else {
echo $location . $name;
echo "<br>";
echo $tmp_name;
}
} else {
echo "Please choose a file!";
}
}
?>
<form action="index.php" method="post" enctype="multipart/form-data">
<input type="file" name="file"><br><br>
<input type="submit" value="Submit">
</form>
empty($_FILES), because$_FILESis always setvar_dump($_FILES)to see if there are any uploads at all