Destroy, delete, unlink files : access denied

Sometimes there are files on a hosted server which can not be deleted by FTP even if you are logged in as the domain administrator. This happens for example when you upload a file using PHP. These files will be marked as being owned by the Apache (or Fast-CGI) user. So when you log into the FTP or the Plesk or Confixx desktop with your own user id, you can’t delete or change the files PHP has uploaded as they are owned by another user.

The only way to delete or change these files is to do it by a PHP script. In PHP you delete files by calling the unlink function.

To delete the file test.txt we simply run a PHP script that is located in the same directory.

<?php
$myFile = “test.txt”;
unlink($myFile);
?>

I had this problem a few days ago when I tried to delete an old wordpress installation on a server and it was not possible to delete the uploads folder cretaed by the wordpress application.