note 29515 deleted from function.unlink by imajes

From: Date: Wed, 14 May 2003 01:06:25 +0000
Subject: note 29515 deleted from function.unlink by imajes
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-47938@lists.php.net to get a copy of this message
i spent lots of time trying to unlink a file on a box running w2k / apache 2.0.43 / php 4.3.0 as 'mascha' mentioned you cannot unlink a file that was previously open without closing it first (which makes sense...) my script created a file , then the page had a form (action=$_SERVER["PHP_SELF"]) with a hidden field containing the filename and a submit button called delete. the first thing my script did when 'reloading' after submit was to check if the delete button had put any filename in the $_POST["file"] variable. then it did some testing and tried to unlink the file. This didnt work :( my workaround: i copied the code (for the unlink function) to another file. then i changed my originall scripts form tag to(action="ANOTHER_FILE"). Then, in the other file i did the unlinking procedure and then returned to the original page by using the header function: header("Location: ".$_SERVER["HTTP_REFERER"]); I have tried EVERY mentioned approach here at the 'User Contributed Notes' but this was the only thing that worked with my setup. I hope my approach can help somebody else!

« previous php.notes (#47938) next »