0

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

is what i'm getting for the code

if (file_exists($thumb)) {
    echo "<b>$thumb</b>";
    $fh = fopen($thumb, 'w') or die("can't open file");
    fclose($fh);
    unlink($myFile);
}

I can confirm that the path of $thumb is correct.

Any fixes?

Thanks in advance.

willium
  • 2,048
  • 5
  • 25
  • 34
  • 1
    What is `$myFile`? Can you confirm that _it is_ correct? – Darryl E. Clarke Nov 28 '10 at 02:59
  • Try `realpath($thumb)`. If it's not within the allowed `open_basedir` then reconfigure your php.ini. – mario Nov 28 '10 at 04:07
  • @mario The problem is on the unlink, not the thumb. realpath() wouldn't make a difference anyway; it just tidies things up, but you end up getting the same file either way. – El Yobo Nov 28 '10 at 05:32

1 Answers1

2

Look in your php.ini setup. The open_basedir configuration setting restricts which areas of the filesystem your PHP script can access; if the file you're trying to delete is outside any directories specified there the unlink() call will fail.

El Yobo
  • 14,823
  • 5
  • 60
  • 78