Cannot delete files created by a script. What should I do to fix the problem?
  ru en
Help
Print version

Cannot delete files created by a script. What should I do to fix the problem?

By default, the web server operates under own user name (e.g., www), and usual mod_php is used for PHP operation, thus, the files being created at the hosting servers using PHP script get the "www owner" and can be deleted only by PHP tools (for example, when own file manager is available in CMS). Besides, these files can be deleted by creating a separate script which will set 777 permissions to the required directories and files (see php function — chmod) or delete them (unlink and rmdir functions). You can also contact the technical support department with a request to delete such files and directories. The script which sets 777 permissions to ALL files of httpdocs directory is given below.

<?
$path=$_SERVER["DOCUMENT_ROOT"];
recursiveChmod($path);
function recursiveChmod($path, $filePerm=0777, $dirPerm=0777)
{
if(!file_exists($path))
{
return(FALSE);
}
if(is_file($path))
{
chmod($path, $filePerm);
} elseif(is_dir($path)) {
$foldersAndFiles = scandir($path);
$entries = array_slice($foldersAndFiles, 2);
foreach($entries as $entry)
{
recursiveChmod($path."/".$entry, $filePerm, $dirPerm);
echo $entry;
echo "<br>";
}
chmod($path, $dirPerm);
echo $path;
}
return(TRUE);
}
?>
Copyright © 2000-2024 Registrar R01
Information: info@r01.ru
Support: support@r01.ru
Office: 1 Bolshoy Gnezdnikovsky Lane, building 2, Moscow (Tverskaya metro station, entrance No. 9, Voznesensky business center)