Answer the question
In order to leave comments, you need to log in
Removing files from hosting?
I have a website and every day there is a rush of files, so I need it so that when I go to site.ru/maps1/clear.php, all files from maps1/files are deleted, so I tried this script does not work
<?php>
if (file_exists('./maps1/files'))
foreach (glob('./maps1/files/*.png') as $file)
unlink($file);
?>
<?php>
if (file_exists('./maps1/files'))
foreach (glob('./maps1/files/*.png') as $file)
unlink($file);
?>
Answer the question
In order to leave comments, you need to log in
Problem with directory and file paths. Try adding paths to full absolute ones, like /var/www/site.ru/maps1/files
If the PHP script files hosted on your hosting have access rights 777, then the execution of these scripts may be blocked by the server and you will be shown an error 500. This happens due to the fact that the access rights 777 allow everyone to make any changes to this file, which significantly affects the security and integrity of your site.
if (file_exists($filename)) {
echo "Файл $filename существует";
} else {
echo "Файл $filename не существует";
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question