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.

3
  • 1
    What is $myFile? Can you confirm that it is correct? Commented Nov 28, 2010 at 2:59
  • Try realpath($thumb). If it's not within the allowed open_basedir then reconfigure your php.ini.
    – mario
    Commented Nov 28, 2010 at 4: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
    Commented Nov 28, 2010 at 5:32

1 Answer 1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.