Before uploading check if file exists then delete this image and upload new image using laravel functionality but showing first uploaded image when hitting image url on browser.
I have face this issue when file name and file type are same.
Below my code
$destinationPath = "public/".$destinationPath;
$extension = $file->getClientOriginalExtension();
if($file->isValid() && in_array($extension, $allowedExt)) {
if (\File::exists($destinationPath.$fileName)) {
\File::delete($destinationPath.$fileName);
}
if($file->move($destinationPath, $fileName)) {
return true;
}
} return false;
Also I have cleared all cache and tried on another PC.
Following commands used to clear the cache.
- php artisan cache:clear
- php artisan config:clear
- php artisan route:clear
Please give me Any suggestions to resolve this issue.