I am unable to upload files to my CentOS 7 server running httpd using php.

I have searched all over and still cannot figure out why I am unable to upload files. :(

Here is the form:

```
<div class="container">
    <div class="row">
        <div class="col-lg-4 col-lg-offset-4">
            <h2 class="section-heading text-white text-center">Private Upload Page</h2>
            <hr class="light">
            <form class="form-horizontal" role="form" action="upload.php" method="post" enctype="multipart/form-data">
              <div class="form-group">
              <span class="text-white">Select directory to upload to:</span><br>
              <input class="form-control" type="text" name="dir" value="/var/www/html/Private/uploads" style="width: 100%;"><br>
              <span class="text-white">Select file to upload:</span><br>
              <input class="form-control" type="file" name="fileToUpload" id="fileToUpload" style="width: 100%;"><br>
              <input class="form-control btn btn-primary" type="submit" value="Upload File" name="submit" >
            </form>
        </div>
    </div>
</div>

```

And here is the php file:

```
<?php
// Check directory from form, otherwise use uploads folder in 
// /var/www/html/Private
if(isset($_POST["dir"])) {
    $target_dir = $_POST["dir"];
    echo "<p>Using " . $target_dir . " for directory.</p><br>";
}
else {
    $target_dir = "/var/www/html/Private/uploads/";
    echo "<p>Using /var/www/html/Private/uploads for directory.</p><br>";
}

$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
$uploadOk = 1;

// Check if file already exists
if (file_exists($target_file)) {
    echo "Sorry, file already exists.";
    $uploadOk = 0;
}
// Check if $uploadOk is set to 0 by an error
if ($uploadOk == 0) {
    echo "Sorry, your file was not uploaded.";
// if everything is ok, try to upload file
} else {
    if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
        echo "The file ". basename( $_FILES["fileToUpload"]["name"]). " has been uploaded.";
    } else {
    echo "Sorry, there was an error uploading your file.";
    }
}
?>

```

I have tried setting using:

```
chmod 777 /var/www/html

```

and:

```
chmod 777 /var/www

```

as well as turned on file write in the php.ini file

as well as turning off the firewall and am still unable to upload a file. 

I am newish to web design, so I'm sure it is an issue that I caused. Every page I looked at pointed to permissions but even allowing 777 still did not fix my issue.