is_dir(): open_basedir restriction in effect. File is not within the allowed path(s)

Taki kawałek kodu mi się trafił, który zaczął pokazywać błąd PHP

is_dir(): open_basedir restriction in effect. File is not within the allowed path(s)

if (!is_dir('/ścieżka/do/katalogu')) {
  // kod
}

Niestety bez dostępu do ustawień PHP musiałem trochę pokombinować i finalnie użyłem funkcji realapth() która zmienia ścieżkę względną na pełną ścieżkę systemową.

Wygląda to mniej więcej tak :

$realPath = realpath('/ścieżka/do/katalogu');
if (!$realPath && !is_dir($realPath)) {
  // kod
}

Dodaj komentarz

Twój adres e-mail nie zostanie opublikowany. Wymagane pola są oznaczone *