Page 1 of 1

unlink()

Posted: Tue Dec 20, 2005 9:36 am
by php3ch0
Can you use unlink() to delete the file it was called in or will this file be open read only?

Posted: Tue Dec 20, 2005 9:42 am
by onion2k
You can on Windows.

Code: Select all

<?php

	unlink("unlink.php");

?>

Posted: Tue Dec 20, 2005 9:43 am
by php3ch0
I take it that you cant on linux. My server is running linux.

Posted: Tue Dec 20, 2005 9:47 am
by onion2k
php3ch0 wrote:I take it that you cant on linux. My server is running linux.
I get a permission denied error on Linux. I take it you're writing an install script?

Posted: Tue Dec 20, 2005 9:50 am
by php3ch0
Yes I need it to delete itseslf after installing.

Posted: Tue Dec 20, 2005 10:10 am
by Corvin Gröning
Why you don't do it like in other install scripts? Simply display a message that the actual file should be deleted because of security issues...

Posted: Tue Dec 20, 2005 1:35 pm
by John Cartwright
What Ive seen other scripts do is check for the existance of the install files prior to allowing the execution of any code.

Code: Select all

if (file_exists('/installation/install.php')) {
   die ('Please delete the .... because.. security.. blah');
}

Posted: Wed Dec 21, 2005 3:12 am
by php3ch0
That will definately work. I was hoping to do it automatically to save any extra work for the user.

Thanks people