This is what I am doing check if file exists and echo in the page, but page shows the old image even when it's already replaced by another image it just shows the old one, but the new image is there and the old one was replaced by the new image with the same name.
<?php
$dir = 'up/images/'.$_SESSION ['username'].'.png';
if (file_exists($dir)) {
//echo "ok";
echo '<img src="up/images/'.$_SESSION['username'].'.png" class="img-responsive img-thumbnail" width="200px;" height="200px;">';
} else {
//not found
echo '<img src="img/user-icon-yellow.png" class="img-responsive img-thumbnail" width="200px;" height="200px;">';
}
?>
It looks like a cache problem or something.