July 27, 201115 yr Hey lads, having abit of trouble with a cron job. Keep getting errors when i use Unlink, it is excuted in a while as the paths are stored in a DB. I know the file exisits, do i need a full path? here is the errors: Warning: unlink(uploads/MIC_5617swp1.jpg): No such file or directory in /home2/buyit/public_html/cron.php on line 72 Warning: unlink(uploads/P11105431.jpg): No such file or directory in /home2/buyit/public_html/cron.php on line 72 Warning: unlink(uploads/littlebrowndogrunning.jpg): No such file or directory in /home2/buyit/public_html/cron.php on line 72 Warning: unlink(uploads/disney.jpg): No such file or directory in /home2/buyit/public_html/cron.php on line 72 Thanks in advance, Adam
July 27, 201115 yr Its probably easiest to give it the full path, especially if you're calling it from a cron job
July 27, 201115 yr Uusually when dealing with files I like to go from doc root: unlink($_SERVER['DOCUMENT_ROOT']."/images/image.jpg"); However cron jobs run from command line so don't have access to _SERVER. I use the following: $root = dirname(__FILE__); unlink($root . "/images/images.jpg");
Create an account or sign in to comment