delete cache on webhosting
- Cheatr01
- Member | 3
Hi guys,
i have a problem with delete cache my Nette app on my hosting. In have this action in one of my presenter:
`
public function actionDeltemp(): void {
FileSystem::delete(__DIR__ . '..\\..\\..\\temp\\cache\\');
die();
}
On localhost works fine but on hosting don`t work.
Thanks for your help…
- nightfish
- Member | 517
Inspect error_log on your server to find any useful detail. And if that does not help you solve the problem, share them here.
EDIT: but there is a good chance the server runs on Linux, so you should prefer platform-agnostic directory separator:
FileSystem::delete(__DIR__ . \DIRECTORY_SEPARATOR.'..'.\DIRECTORY_SEPARATOR.'..'.\DIRECTORY_SEPARATOR.'..'.\DIRECTORY_SEPARATOR.'temp'.\DIRECTORY_SEPARATOR.'cache'.\DIRECTORY_SEPARATOR);
or maybe a more _compact_ approach:
FileSystem::delete(\implode(\DIRECTORY_SEPARATOR, [__DIR__, '..', '..', '..', 'temp', 'cache', '']))
Last edited by nightfish (2019-02-03 20:53)
- Pavel Kravčík
- Member | 1195
@nightfish: And you can save three chars by using join()
instead of implode
.