In my laravel project, I have a form for uploading a file and removing it. I create a disk in config/filesystem:
'upload' => [
'driver' => 'local',
'root' => public_path(),
'url' => env('APP_URL'),
'visibility' => 'public',
],
Here uploading file work correctly but when I want remove them from public folder the file not exist:
$img_path = public_path( $this->directory . '/' . $this->getFliename());
$img_path = str_replace( "/",'\\', $img_path); // checked with it & without it
// $img_path= "C:\Users\Me\Desktop\final\public\upload\users\1\5bc722d2b7c05.jpg"
dump(File::exists($img_path)); // it always return false
// and then which one
File::delete($img_path);
Storage::disk('upload')->delete($img_path);
why this file doesn't exist, and which one for deleting a file is true?
It becomes more complicating when I do it with route???
// testing ...
Route::get('/test', function (){
File::delete('C:\Users\Me\Desktop\final\public\upload\users\1\5bc722d2b7c05.jpg');
});