note 29515 added to function.unlink
| From: | cyberleif at rack1 dot php dot net | Date: | Sun, 16 Feb 2003 04:50:59 +0000 |
| Subject: | note 29515 added to function.unlink | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-44042@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!
--
http://www.php.net/manual/en/function.unlink.php
http://master.php.net/manage/user-notes.php?action=edit+29515
http://master.php.net/manage/user-notes.php?action=delete+29515
http://master.php.net/manage/user-notes.php?action=reject+29515