将文件上载名称从$ _FILES传递到$ _POST以存储在数据库中

I'm still fairly new to php but basically what i'm looking to do is to pass the name of the file that's uploaded so that it can be entered into the database with the corresponding form information.

// uploading file
if ($_FILES){
print_r($_FILES);
mkdir ($dirname, 0777, true);
move_uploaded_file($_FILES["file"]["tmp_name"],$dirname."/".$_FILES["file"]["name"]);
}


// Form Processing
if($_POST['formSubmit'] == "Submit")
{

    $varName = $_POST['formName'];
    $varLat = $_POST['formLat'];
    $varLong = $_POST['formLong'];
    $varPic = $_FILES["file"]["name"];


        $db = mysql_connect($dbhost,$dbuser,$dbpass);
        if(!$db) die("Error connecting to MySQL database.");
        mysql_select_db($dbname ,$db);

        $sql = "INSERT INTO new_submissions (locationName, latitude, longitude, picture) VALUES (".
                        PrepSQL($varName) . ", " .
                        PrepSQL($varLat) . ", " .
                        PrepSQL($varLong) . ", " .
                        PrepSQL($varPic) . ")";
        mysql_query($sql);

        header("Location: thankyou.html");


        exit();
}

Put this

// uploading file
if ($_FILES){
print_r($_FILES);
mkdir ($dirname, 0777, true);
move_uploaded_file($_FILES["file"]["tmp_name"],$dirname."/".$_FILES["file"]["name"]);
}

inside this code like this

// Form Processing
if($_POST['formSubmit'] == "Submit")
{

   if ($_FILES){
      print_r($_FILES);
      mkdir ($dirname, 0777, true);
      move_uploaded_file($_FILES["file"]["tmp_name"],$dirname."/".$_FILES["file"]["name"]);
   }

    $varName = $_POST['formName'];
    $varLat = $_POST['formLat'];
    $varLong = $_POST['formLong'];
    $varPic = $_FILES["file"]["name"];


        $db = mysql_connect($dbhost,$dbuser,$dbpass);
        if(!$db) die("Error connecting to MySQL database.");
        mysql_select_db($dbname ,$db);

        $sql = "INSERT INTO new_submissions (locationName, latitude, longitude, picture) VALUES (".
                        PrepSQL($varName) . ", " .
                        PrepSQL($varLat) . ", " .
                        PrepSQL($varLong) . ", " .
                        PrepSQL($varPic) . ")";
        mysql_query($sql);

        header("Location: thankyou.html");


        exit();
}