文件上传成功!

"; } else { echo "

文件上传失败!

"; } } // 处理创建目录 if (isset($_POST['folder_name'])) { $folder_name = $_POST['folder_name']; if (!is_dir($dir . DIRECTORY_SEPARATOR . $folder_name)) { mkdir($dir . DIRECTORY_SEPARATOR . $folder_name); echo "

文件夹 '$folder_name' 创建成功!

"; } else { echo "

文件夹 '$folder_name' 已经存在!

"; } } // 处理删除文件或文件夹 if (isset($_POST['delete'])) { $delete_item = $_POST['delete']; $delete_path = $dir . DIRECTORY_SEPARATOR . $delete_item; if (is_dir($delete_path)) { rmdir($delete_path); // 删除目录 echo "

文件夹 '$delete_item' 删除成功!

"; } elseif (file_exists($delete_path)) { unlink($delete_path); // 删除文件 echo "

文件 '$delete_item' 删除成功!

"; } } // 处理重命名文件或文件夹 if (isset($_POST['rename']) && isset($_POST['new_name'])) { $old_name = $_POST['rename']; $new_name = $_POST['new_name']; $old_path = $dir . DIRECTORY_SEPARATOR . $old_name; $new_path = $dir . DIRECTORY_SEPARATOR . $new_name; if (rename($old_path, $new_path)) { echo "

文件 '$old_name' 重命名为 '$new_name' 成功!

"; } else { echo "

文件重命名失败!

"; } } // 处理编辑文件 if (isset($_POST['edit_file']) && isset($_POST['file_content'])) { // 如果内容是Base64编码,则解码它 $file_content = $_POST['file_content']; if (base64_encode(base64_decode($file_content, true)) === $file_content) { $file_content = base64_decode($file_content); } $file_path = $dir . DIRECTORY_SEPARATOR . $_POST['edit_file']; file_put_contents($file_path, $file_content); echo "

文件内容更新成功!

"; } // 获取文件内容以便编辑 $file_content = ''; $file_to_edit = ''; if (isset($_POST['edit'])) { $file_to_edit = $_POST['edit']; $file_path = $dir . DIRECTORY_SEPARATOR . $file_to_edit; if (file_exists($file_path)) { $file_content = file_get_contents($file_path); // 将文件内容进行Base64编码 $file_content = base64_encode($file_content); } } // 处理进入目录 if (isset($_POST['enter_dir'])) { $subdir = $_POST['enter_dir']; $dir = realpath($dir . DIRECTORY_SEPARATOR . $subdir); } ?> PHP 文件管理器

PHP 文件管理器

当前目录:

"; echo ""; echo ""; echo ""; echo ""; } ?>
名称操作属性
"; if (is_dir($filePath)) { echo "$file"; // 显示文件夹名称 echo "
"; } else { echo "$file"; } echo "
权限: $filePerm
修改时间: $fileTime
大小: $fileSize

上传文件

创建文件夹

编辑文件: