PhP file download does not work, well until download


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.

    $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">

your $locatIon is probably wrong, try passing an absolute path ( the path in your example is relative to the current working directory, and it may not be writable )