2017-06-02 4 views
0

私はこのようなファイルを削除した場合:laravel 5.3のフォルダを削除するにはどうすればよいですか?

$destinationPath = public_path() . DIRECTORY_SEPARATOR . 'img'. DIRECTORY_SEPARATOR . 'products' . DIRECTORY_SEPARATOR . $id; 
$result = File::delete($destinationPath . DIRECTORY_SEPARATOR . $filename); 

それは

を動作しますが、私はこのようなフォルダを削除する場合:削除フォルダがない理由

$destinationPath = public_path() . DIRECTORY_SEPARATOR . 'img'. DIRECTORY_SEPARATOR . 'products' . DIRECTORY_SEPARATOR . $id; 
File::delete($destinationPath); 

それは

を動作しませんが作業?

どうすればこの問題を解決できますか?

+4

あなたが最初にGoogleをチェックする必要があり、これは私の検索したディレクトリlaravel'削除 ':)最初のリンクで解決策を得ました。 – Webinion

+2

[Laravelのファイルを含むフォルダを削除する](https://stackoverflow.com/questions/41207731/deleting-a-folder-with-files-in-laravel) – JazzCat

答えて

2

間違った方法を使用しようとしています。あなたはdeleteDirectoryなくdeleteを使用する必要があります。

$destinationPath = public_path('img/products/'. $id); 
File::deleteDirectory($destinationPath); 
+0

今すぐ解決されました –

+0

どのクラスが必要ですかこれに含めるべきか? –

関連する問題