0

I am using the code below remove an image file. The files is removed but there is still an error shown. Any suggestions?

Warning: unlink() [function.unlink]: open_basedir restriction in effect. File() is not within the allowed path(s):

<?php
session_start(); //session start

if(isset($_SESSION['access_token']) && $_SERVER['REQUEST_METHOD'] == 'POST')
{
    $check_image = glob('../uploads/logo_'.$_SESSION['relatie_id'].'.*');
    unlink($check_image[0]);

    echo '<div class="alert alert-success text-center" role="alert">Met succes verwijderd.</div>';
}
?>
Muiter
  • 1,470
  • 6
  • 26
  • 39
  • Possible duplicate of [open_basedir restriction in effect. File(/) is not within the allowed path(s):](https://stackoverflow.com/questions/1846882/open-basedir-restriction-in-effect-file-is-not-within-the-allowed-paths) – Joe Black Jun 17 '17 at 19:15
  • Look at open_basedir option in php.ini: http://php.net/manual/en/ini.core.php#ini.open-basedir You can use "chdir()" to change to that directory, or change open_basedir on runtime – Tamar Jun 17 '17 at 20:18

1 Answers1

0

Try this function

 function delete($dir, $file) {
   $file = $dir . '/' . $file;
   if ((file_exists($file)) && (@unlink($file)) ) {
     return true;
   }
   return false;
 }
Muhammad Usman
  • 1,403
  • 13
  • 24