For a filemanagement, i am using the var $dir
that shows me the path to the folders.
My url string looks like this:
www.example.com/index.php?dir=uploads/folder1
Below is how i grab the path for navigation:
$MainFolderName = 'uploads';
$dir = $MainFolderName;
/* Read actual dir from url */
$actual_link = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
$strArr = explode("=",$actual_link);
$CurrentPath = $strArr[1];
// if new folder is created
if(isset($_GET['dir'])) {
$dir = $CurrentPath;
}
To navigate, i use anchors like below:
foreach ($files as $file) {
.........
if(is_dir($dir.'/'.$file)) {
$folderanchor = "<a class='folderanchor' href='?dir=".$dir.'/'.$file."'><i class='fas fa-folder'></i>$file</a>";
echo $folderanchor;
So navigate like this gives always a complete page loading.
How can i make this navigation with ajax, so loading dynamically?
I know it has something to do with the GET
but i dont know how to handle with this...
By the way: for reading all files and directories in a folder is use
// exclude dot, double dot and tmp folder
$files = array_diff( scandir($dir), array(".", "..", "tmp") );