I have a php file to delete day old images from the server and update the database every hour
$downloadDeleteQuery = mysql_query("SELECT * FROM images WHERE timeleft < 1") or die(mysql_error());
while($downloadDelete = mysql_fetch_array($downloadDeleteQuery)){
$name = $downloadDelete['name'];
$myFile = "../watermarked/".$name;
$fh = fopen($myFile, 'w') or die("");
fclose($fh);
unlink($myFile);
}
That is the code to delete the files from the server. This file is run as a cronjob and works every hour editing the database but it doesn’t delete the files, but when you go to the file directly http://www… etc it works as intend. Is this a permission error or something else?
Thanks
Try adding the full path, I have had to deal with this before as well. Instead of
$myFile = "../watermarked/".$name;try$myFile = "/home/user/path/to/watermarked/".$name;This will allow to system to see it since the crons are executed by the system. It doesn’t initially take the location of the executed files into account.