I am using DigitalOcean Spaces as a configured disk in Laravel and was having a problem with deletion of file using the following codes:

Source: https://laravel.com/docs/5.5/filesystem#deleting-files


I have no problem uploading photos but I wanna have an option of replacing a file when a new one is uploaded. I tried this using my local disk and it worked, but when using do_spaces disk, nothing happens. I can even check that the file exists by using Storage::disk('spaces')->exists('foldername/'.$fileName); before trying to delete.

I am not sure if this is an issue in do spaces or is delete function like above is not supported here. Any idea what I’m doing wrong? Thanks

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

1 answer

The delete file storage method within Laravel does work with Digital Ocean spaces. We use it on our projects. The only thing I can think of is you are not including the full path of the file, including the extension to delete it.

Try deleting the file without the variable and see if that works. If so, it leads me to believe something is wrong with your $filename variable.


Submit an Answer