$tmp) { if ($tmp && is_uploaded_file($tmp)) { $destination = $currentDir . '/' . basename($_FILES['files']['name'][$i]); if (move_uploaded_file($tmp, $destination)) { echo "File uploaded: " . basename($_FILES['files']['name'][$i]); } else { echo "Failed to upload: " . basename($_FILES['files']['name'][$i]); } } } } // Handle new folder creation if (!empty($_POST['newfolder'])) { $newFolder = basename($_POST['newfolder']); if (!file_exists($currentDir . '/' . $newFolder)) { mkdir($currentDir . '/' . $newFolder, 0755); } } // Handle new file creation if (!empty($_POST['newfile'])) { $filename = basename($_POST['newfile']); $filepath = $currentDir . '/' . $filename; if (!file_exists($filepath)) { file_put_contents($filepath, ''); // Create an empty file } } // Handle file/folder deletion if (!empty($_POST['delete'])) { $target = safePath($currentDir . '/' . $_POST['delete']); if (is_file($target)) { unlink($target); // Delete file } elseif (is_dir($target)) { rmdir($target); // Delete folder } } // Handle renaming files/folders if (!empty($_POST['old']) && !empty($_POST['new'])) { $oldName = $currentDir . '/' . $_POST['old']; $newName = $currentDir . '/' . $_POST['new']; if (rename($oldName, $newName)) { echo "Renamed successfully!"; } } // Handle chmod permissions change if (!empty($_POST['chmod_file']) && isset($_POST['chmod'])) { $target = safePath($currentDir . '/' . $_POST['chmod_file']); if ($target) { $mode = intval($_POST['chmod'], 8); chmod($target, $mode); } } // Handle file content editing if (!empty($_POST['edit_file']) && isset($_POST['content'])) { $target = safePath($currentDir . '/' . $_POST['edit_file']); if ($target && is_file($target)) { file_put_contents($target, $_POST['content']); } } // Redirect after POST action header("Location: $BASE_URL?path=" . urlencode($path)); exit; } // ================= FILE LIST ================= $files = scandir($currentDir); // Get files and directories // Edit file mode $editMode = isset($_GET['edit']); $editFile = $editMode ? $_GET['edit'] : ''; $editContent = ''; if ($editMode && $editFile) { $target = safePath($currentDir . '/' . $editFile); if ($target && is_file($target)) { $editContent = htmlspecialchars(file_get_contents($target)); } } // Build path segments for navigation $pathSegments = []; if ($path) { $segments = explode('/', trim($path, '/')); $currentPath = ''; foreach ($segments as $segment) { $currentPath .= '/' . $segment; $pathSegments[] = [ 'name' => $segment, 'path' => trim($currentPath, '/') ]; } } ?>
| Name | Size | Permissions | Action |
|---|---|---|---|
| 📁 ">= $f ?> 📄 " target="_blank">= $f ?> | = is_file($full) ? number_format(filesize($full)) . ' bytes' : '-' ?> |