Current Path: $currentPath
"; // 确保路径是合法的 if (strpos($currentPath, $basePath) !== 0) { die("Invalid directory."); } // 列出当前目录下的文件 if (isset($_GET['list'])) { $files = scandir($currentPath); echo "" . htmlspecialchars(file_get_contents($filePath)) . ""; } else { echo "File does not exist."; } } // 新建文件 if (isset($_POST['create'])) { $newFileName = $_POST['filename']; $filePath = $currentPath . DIRECTORY_SEPARATOR . $newFileName; if (file_put_contents($filePath, "") !== false) { echo "File '$newFileName' created successfully."; } else { echo "Failed to create file."; } } ?>