Be aware that Storage::exists() uses the default disks, storage path.. Check your filesystems.php file to see what the path is for the default disk. My suggestion is to create a new disk, and set its path to public_path("images/product/) and then use that.
Aug 30, 2021
2
Level 1
Storage::exists returns false
Hi, i'm writing a section in my product controller that checks if the old product image exist and then delete it before updating with the new image path
$newImageName = $product->id.'-'.$request->image->getClientOriginalName();
$newImage = $request->image->move(public_path("images/product/$product->id"),$newImageName);
$oldPath = public_path("images/product/$product->id/").$product->image;
if (Storage::exists(public_path("images/product/$product->id/").$product->image)){
dd('File is exists.');
} else {
dd('File not exist');
}
$oldPath value ="C:\laragon\www\mini\public\images/product/11/11-20119342_10_400.jpg" and it confirm exists. but it always returns fail.
i have no issue uploading the new file in the which will be in "C:\laragon\www\mini\public\images/product/11\11-20112633_01_400.jpg"
is it because of the \ and / since i'm using windows?
Please or to participate in this conversation.