The problem is explained in the error, you cannot delete a folder that is not empty
What does the folder contain?
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I am trying to delete a folder along with files inside it. below is my code
Storage::disk('public')->deleteDirectory($path);
It works fine on my local but when the same is executed on the server it is throwing below error.
[2020-03-10 09:25:02] development.ERROR: rmdir(/var/www/vhosts/trymy.sipcall.ch/storage/app/public/temp/11720_intro): Directory not empty {"userId":40758,"exception":"[object] (ErrorException(code: 0): rmdir(/var/www/vhosts/trymy.sipcall.ch/storage/app/public/temp/11720_intro): Directory not empty at /var/www/vhosts/trymy.sipcall.ch/vendor/league/flysystem/src/Adapter/Local.php:419) [stacktrace] #0 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(2, 'rmdir(/var/www/...', '/var/www/vhosts...', 419, Array) #1 /var/www/vhosts/trymy.sipcall.ch/vendor/league/flysystem/src/Adapter/Local.php(419): rmdir('/var/www/vhosts...') #2 /var/www/vhosts/trymy.sipcall.ch/vendor/league/flysystem/src/Filesystem.php(251): League\Flysystem\Adapter\Local->deleteDir('temp/11720_intr...') #3 /var/www/vhosts/trymy.sipcall.ch/vendor/laravel/framework/src/Illuminate/Filesystem/FilesystemAdapter.php(604): League\Flysystem\Filesystem->deleteDir('temp/11720_intr...') #4 /var/www/vhosts/trymy.sipcall.ch/app/Models/IvrPortaHelper.php(1543): Illuminate\Filesystem\FilesystemAdapter->deleteDirectory('temp/11720_intr...')
Please or to participate in this conversation.