problem with function unlink()
I'd uploaded some files via ftp and then I chmod them 777.
Then I created a php script to manage these files, when I tried to delete a selected file I got this error:
Unlink failed (Permission denied) in /home/sitefolder/public_html/admin/confirm_delete.php on line 93
These are some lines of my script:
<?php
$file=\"/home/sitefolder/public_html/files/file.pdf\";
if (unlink($file)){ //line #93
echo\"file deleted\";
}else{
echo\"ERROR!\";
}
?>
I don't know what's the problem, I had changed the permissions to 777 but the problem persists...
I need your help!!
Thanx
Adolfo
Adolfo posted this at 19:59 — 26th November 2001.
They have: 32 posts
Joined: Jan 2001
I found the problem ...
I chmod 777 the dir where I have my files and I just worked out
Mark Hensler posted this at 22:51 — 26th November 2001.
He has: 4,048 posts
Joined: Aug 2000
You'll want to be carefull with 777 directories. That's a big security whole.
Adolfo posted this at 12:23 — 27th November 2001.
They have: 32 posts
Joined: Jan 2001
I know but, what can I do???
If the dir is not 777 chmoded I cannot unlink either rename
Mark Hensler posted this at 16:27 — 27th November 2001.
He has: 4,048 posts
Joined: Aug 2000
You can find out what user your scripts run as. Then chown and chgrp the folder to that user.
Or... you could create a symbolic link to that folder, and chown and chgrp that to the user. That way, you don't loose ownership.
Mark Hensler
If there is no answer on Google, then there is no question.
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.