0

I've ran into issue where I need to use chdir function and it seems that I need to use full path for it to fully function.

Is there any way of not doing this? I would like to use simplier path like ~/ but it does not work.

        $dir = "files";
        chdir($dir); // "Returns TRUE on success or FALSE on failure" 
        array_multisort(array_map('filemtime', ($filesArray = glob("*.*"))), SORT_DESC, $filesArray); //Tipo sortina kazkaip magiskai
        $dir = "/home/galgalda/domains/tortonas.tk/public_html"; //How do i change this line?
        chdir($dir); 

1 Answers1

0

Yo can try using $_SERVER['DOCUMENT_ROOT']

$dir = "files";
chdir($dir); // "Returns TRUE on success or FALSE on failure" 
array_multisort(array_map('filemtime', ($filesArray = glob("*.*"))), SORT_DESC, 
$filesArray); //Tipo sortina kazkaip magiskai
$dir = $_SERVER['DOCUMENT_ROOT']; //How do i change this line?
chdir($dir); 
RiggsFolly
  • 93,638
  • 21
  • 103
  • 149
JuliSmz
  • 996
  • 1
  • 12
  • 26