I have a problem deleting a directory.
I'm creating a temporary directory where I unzip a file and I want to delete it when I'm done with it.
My code looks pretty much like this:
$tempPath = storage_path('temp/'.$filemd5.'/');
Storage::makeDirectory($tempPath);
$success = Storage::deleteDirectory($tempPath);
return $success;
It doesn't return anything and the directory doesn't get deleted.
I think if you remove the trailing backslash from $tempPath
, it might work.
$tempPath = storage_path('temp/'.$filemd5);
EDIT:
Okay, I tried different methods and looks like the class File
is the most simple one.
File::makeDirectory($path)
and
File::deleteDirectory($path)
More about creating a directory and Deleting a directory
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With