Page 1 of 1

newbie Q - file deletions and permissions problem

Posted: Sat Jun 26, 2004 2:12 pm
by Coco
im trying to delete a text file. Nothing fancy.

No matter what I do, the script always returns permission denied. Chmod set to 777 via ftp.
ive read thru the past posts, and tried stuff ive come accross, but it still wont do it :?

Ive tried:

Code: Select all

<?php
// now delete counter file
$filename = $_SERVER["DOCUMENT_ROOT"] . '/test.txt';
if (file_exists($filename))
{
	chmod($filename, 0777);
	unlink($filename);
	echo 'deleted... apparently';
} 

-------------
// now delete counter file
$filename = $_SERVER["DOCUMENT_ROOT"] . '/test.txt';

if (file_exists($filename))
{
	unlink($filename);
	echo 'deleted... apparently';
} 

------------
// now delete counter file

$filename = './test.txt';
if (file_exists($filename))
{
	unlink($filename);
	echo 'deleted... apparently';
} 


?>
Whats even stranger, is that the chmod command itself is blocked by the server (operation not permitted)
What am i doing wrong? Do i need to get my host to change the setup?
other than doing a chown, i dont know what else to try

Posted: Sat Jun 26, 2004 2:21 pm
by evilmonkey
You might not have chmod permissions, check that with your host...

Posted: Sat Jun 26, 2004 3:30 pm
by Coco
maybe so, but I have the permissions in ftp, and had previously set the files permissions to 777

Posted: Sat Jun 26, 2004 3:43 pm
by Weirdan
man chmod wrote: Only the owner of a file or the super-user is permitted to change the mode of a file.
PHP manual wrote: Note: The current user is the user under which PHP runs. It is probably not the same user you use for normal shell or FTP access.

Posted: Mon Aug 23, 2004 3:37 pm
by ragnew
How do you make the end user the same as the file user so I can avoid the same problem?