php+vue3实现简洁大气的网盘云盘文件管理系统代码
代码语言:php
所属分类:文件
代码描述:php+vue3实现简洁大气的网盘云盘文件管理系统代码,可上传文件单个或多个、可上传目录、可批量删除,还可在线预览播放视频、图片、声音。
代码标签: php vue 简洁 大气 网盘 云盘 文件 管理 系统 代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<?php
// ##################################################################
// # PHP & Vue3 单文件网盘管理系统 #
// # 作者: 专业PHP/HTML全栈工程师 #
// # 版本: 1.1 (支持文件和文件夹分别上传) #
// ##################################################################
// --- 配置区 ---
// 设置你希望管理的根目录的绝对路径,结尾不要加'/'
$root_dir = '/var/www/html/files'; // <-- Linux 示例: /var/www/my_files
// $root_dir = 'C:/www/files'; // <-- Windows 示例: C:/www/files
// 身份验证 (可选, 简单的密码保护)
// 留空则禁用密码: $password = '';
$password = 'admin'; // 在这里设置你的密码
// --- 配置区结束 ---
// --- 后端逻辑处理 ---
session_start();
function check_auth() {
global $password;
if (!empty($password) && (!isset($_SESSION['is_logged_in']) || $_SESSION['is_logged_in'] !== true)) {
return false;
}
return true;
}
function handle_login() {
global $password;
if (isset($_POST['password']) && $_POST['password'] === $password) {
$_SESSION['is_logged_in'] = true;
header('Location: ' . $_SERVER['PHP_SELF']);
exit;
}
return '密码错误';
}
if (!empty($password)) {
if (isset($_GET['action']) && $_GET['action'] == 'logout') {
session_destroy();
header('Location: ' . $_SERVER['PHP_SELF']);
exit;
}
if (!check_auth()) {
if (isset($_POST['password'])) {
$login_error = handle_login();
}
// 显示登录页面
header('Content-Type: text/html; charset=utf-8');
echo <<<HTML
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>登录 - 文件管理系统</title>
<style>
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; display: flex; justify-content: center; align-items: center; height: 100vh; background-color: #f0f2f5; margin: 0; }
.login-container { background: #fff; padding: 40px; border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.1); text-align: center; }
h2 { color: #333; margin-bottom: 20px; }
input { width: 100%; padding: 12px; margin-bottom: 20px; border: 1px solid #ddd; border-radius: 4px; box-sizing: border-box; }
button { width: 100%; padding: 12px; background-color: #007bff; color: white; border: none; border-radius: 4px; cursor: pointer; font-size: 16px; }
button:hover { background-color: #0056b3; }
.error { color: #dc3545; margin-top: -10px; margin-bottom: 10px; }
</style>
</head>
<body>
<div class="login-container">
<h2>系统登录</h2>
<form method="post">
<input type="password" name="password" placeholder="请输入密码" required>
<button type="submit">登录</button>
</form>
HTML;
if (isset($login_error)) {
echo '<p class="error">' . htmlspecialchars($login_error) . '</p>';
}
echo '</div></body></html>';
exit;
}
}
$action = $_GET['action'] ?? '';
if (!empty($action)) {
// API请求,关闭HTML输出
error_reporting(0);
header('Content-Type: application/json; charset=utf-8');
// 安全函数:确保路径在根目录内
function get_safe_path($path) {
global $root_dir;
// 移除路径中的 '..'
$path = str_replace('..', '', $path);
// 拼接成绝对路径
$ful.........完整代码请登录后点击上方下载按钮下载查看















网友评论0