Php: Unlink()

liunx

Guest
I'm attempting to use unlink($file) without any results. Is that function disabled in our PHP configuration? Or, am I doing something wrong? I've passed both relative and absolute paths -- and verified (file_exists()) that the filename is correct... no luck.<br /><br />Any work-arounds?<br /><br />I'm trying to delete files based on user parameters (i.e., date/time).<br /><br />Thanks,<br />Bill<!--content-->
Make sure to set the CHMOD of the PHP script correctly. Make sure to CHMOD the folder correctly. And the files, too.<br /><br />I've got a PHP script that uses unlink() and the function does work....<br /><br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->unlink("../dir1/dir2/$Game_ID.$Ext");<!--c2--></div><!--ec2--><br />is one modified snippet. CHMODS -- The PHP script executing it is 644, the folder the script is in is 755, the folder the file is in is 777 (I could tinker with this, but wont), and the file itself is in 644.<!--content-->
Keep in mind that if you are running the PHP script as a webpage, it runs as user "nobody", not as you. So if the files it is trying to remove do not have world write permission set, they will fail.<!--content-->
Aaah! It was the folder -- adding public writable solved the problem. <br /><br />Strange, the script can upload files to that directory, thought unlink would work too.<br /><br />Thanks for the help. <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/kicking.gif" style="vertical-align:middle" emoid=":dance:" border="0" alt="kicking.gif" /><!--content-->
 
Back
Top