I am trying to display whatever is stored in a variable depending on what the user does, if they upload a photo then it is stored in the $SellPhoto2 variable but if they dont "defaultcar.jpg" is stored in the variable, here is what I have so far:
if(is_uploaded_file($_FILES["SellPhoto2"]['name']))
{
if ($CheckFileType2 != "jpg")
{
echo '<div class="alert alert-danger">' . "You are trying to upload a " . pathinfo($_FILES['SellPhoto2']['type'], PATHINFO_EXTENSION) . " file, the file must be either .jpg." . '</div>';
}
if (file_exists('images/' . $_SESSION["info"]["id"] . '/' . $_FILES['SellPhoto2']['name']))
{
echo '<div class="alert alert-danger">The file name you are trying to upload as your second photo already exists, please rename your file.</div>';
}
$SellPhoto2 = $_FILES['SellPhoto2']['name'];
}
else
{
$SellPhoto2 = "defaultcar.jpg";
}
var_dump($SellPhoto2);
This is the var_dump:
string(14) "defaultcar.jpg"
When I upload a file it displays "defaultcar.jpg" when it should actually display the uploaded file, does anyone understand what I am doing wrong?