Hello everyone,
I have a datingsite with users who can upload pictures to a certain directory.
Now I'm working on a administration page where I can delete users from my site.
Programming the part of deleting the picture uploaded by the user. I get this error :
unlink(): SAFE MODE Restriction in effect. The script whose uid is 20136 is not allowed to access / owned by uid 0 in
When the user uploads the file i chmod the file with 0777.
Wenn the user loggs in , he can delete is own picture. But wenn I try it. I get the error.
I working on a shared server with safe mode on. There is no ini file available.
What can I do to delete the picture from a php script ?
Thanks in advance
unlink(): SAFE MODE Restriction in effect! Help
Moderator: General Moderators
This is interesting.. I think your script is not looking in the right place for the unlink. UID of 0 is 'root'.. I'm assuming that files being uploaded should be owned by a standard user or 'apache' or 'nobody'unlink(): SAFE MODE Restriction in effect. The script whose uid is 20136 is not allowed to access / owned by uid 0 in
So it's saying that your script (20136 is the owner of that file) is trying to delete a file that is owned by (0 who is root).. and it says that is not allowed to access / which is the root filesystem. Are you adding a complete path in your unlink() call?
Code: Select all
unlink('/path/to/image/file/imagefile.jpg');This is the the function that I call :
the picture of guestbook is stored in http://www.mydomain.com/community/logos
the picture name is stored in the db(logolink) fe. johnny.jpg
the picture of guestbook is stored in http://www.mydomain.com/community/logos
the picture name is stored in the db(logolink) fe. johnny.jpg
Code: Select all
function PHP_Delete_Guestbook_Picture($name)
{
include ("e;conn.php"e;);
mysql_select_db($db1,$conn);
$sql = "e;SELECT logolink FROM users WHERE name='$name' LIMIT 1;"e;;
$result = mysql_query($sql,$conn);
$myrow = mysql_fetch_array($result);
if ($myrowї'logolink']!="e;"e;)
{
$filename = "e;/community/logos/"e;.$myrowї'logolink'];
echo "e;try to delete "e;.$filename."e;<br>"e;;
unlink($filename);
}
}Already a lot of thanks for the reply's . I tried it with ftp connection
It is still not working.
This is the code i used :
It is still not working.
in my file line 17 = ftp_delete($conn_id, $filename)Warning: ftp_delete(): Delete operation failed. in /srv/www/htdocs/web53/html/community/logos/delete_pic.php on line 17
could not delete
This is the code i used :
Code: Select all
$ftp_server = "myserver";
$filename = "/community/logos/johnny.jpg";
// set up basic connection
$conn_id = ftp_connect($ftp_server) or die("Couldn't connect to $ftp_server");
// login with username and password
$login_result = ftp_login($conn_id, "user", "password") or die("Couldn't login to $ftp_server");
// try to delete $file
if (ftp_delete($conn_id, $filename)) {
echo "$file deleted successful\n";
} else {
echo "could not delete $file\n";
}
// close the connection
ftp_close($conn_id);Try using 'complete' path as suggested for unlink...
HTH
hanji
Code: Select all
$filename = "/srv/www/htdocs/web53/html/community/logos/".$myrow['logolink'];
echo "try to delete ".$filename."<br>";
unlink($filename);hanji