Search code examples
laravellaravel-5laravel-5.4laravel-storage

Storage::exists tells me the file exists but I can't delete it with Storage::delete


I'm trying to delete a file inside a folder with:

Storage::delete(strtolower($fileGroup->name) . '/' . $file->filename);

But it returns false and when I check the file it's still there. When I see if the same file exists with:

Storage::exists(strtolower($fileGroup->name) . '/' . $file->filename));

It returns true.

Does anyone know what i'm doing wrong? I'm using local storage with all the default settings.


Solution

  • I found the problem. When uploading the file, Storage::put created a folder with the filename instead of a file. So it failed when I tried to delete it.

    Storage::put($fileGroup->name . '/' . $file->getClientOriginalName() , file_get_contents($file));