I am creating a file system that lists all the folders in your server. I can create and delete any folder. But the problem is when I am inside a sub-folder and delete another sub-folder, the website redirects me back to the root folder. I want to refresh and update only the changes rather than redirect me to the root folder.
here is the code of how I am creating new folder:
<form id="folder-form" name="folder-form" method="post" action="my-home.php">
<p>Create a new folder</p>
<div class="folderInput">
<input type="text" name="folder-name" id="name" placeholder="Folder Name"/>
</div>
<div class="folderBtn">
<button type="submit" value="Create Folder" id="createFolder">Ok</button>
</div>
</form>
and this is how I am retrieving the new folder information using isset:
if (isset($_POST['folder-name'])) {
echo $_SESSION['currentDir'].$_SESSION['folderName'].'/';
$folder = $_SESSION['currentDir'].$_SESSION['folderName']."/".$_POST['folder-name'];
if (!file_exists($folder)) {
mkdir($folder, 0777);
}
}
This is the delete link:
<a href="#" id="delete" onclick="deleteForm.submit()">Delete</a>
and this is how I am retrieving the information using the isset
if (isset($_POST['select'])){
foreach ($_POST['select'] as $file) {
deleteFiles($_SESSION['currentDir'].$_SESSION['folderName']."/".$file);
}
}
Note that in every row I have a checkbox for the delete function:
<input name="select[]" type="checkbox" class="select" value="folder name"/><