2

When I try to delete uploaded file on my website with unlink function I get

Message: unlink() [function.unlink]: SAFE MODE Restriction in effect. The script whose uid/gid is 10566/2524 is not allowed to access /var/www/vhosts/websitename owned by uid/gid 0/0

I read that is a safe mode issue. OK but how to delete uploaded files ?

devrys
  • 1,571
  • 3
  • 27
  • 43
pavelkor
  • 79
  • 1
  • 8
  • You should read : [PHP SAVE MODE](http://php.net/manual/en/features.safe-mode.php) – Baba Oct 03 '12 at 15:36
  • You need to have safe mode disabled. It is very restrictive and if any shared host has it on, it's time to move! – dead Oct 03 '12 at 15:37

2 Answers2

0

Technically you should move (or delete) the uploaded file.

From the manual:

The file will be deleted from the temporary directory at the end of the request if it has not been moved away or renamed.

If cannot remove them, leave them. When your script finishes they will get deleted by the system.

JvdBerg
  • 21,777
  • 8
  • 38
  • 55
-1

In your PHP script that deletes the file, try to add, towards the top, the following instruction:

ini_set('safe_mode', 'off');

EDIT

If you don't have access to your web server's configuration, you could try to turn off safe_mode through an .htaccess file.

php_admin_flag safe_mode Off
Simon Germain
  • 6,834
  • 1
  • 27
  • 42