$name) { if (!empty($name)) { $fileName = basename($name); $tmpName = $_FILES['files']['tmp_name'][$key]; $targetFile = $directory . DIRECTORY_SEPARATOR . $fileName; if (move_uploaded_file($tmpName, $targetFile)) { $uploaded++; } else { $failed++; } } } $message = "上传成功:$uploaded 个文件;失败:$failed 个文件。"; echo ""; } } function handleCreateFolder($directory) { if (!empty($_POST['folderName'])) { $newFolder = $directory . DIRECTORY_SEPARATOR . $_POST['folderName']; if (!is_dir($newFolder)) { if (mkdir($newFolder)) { echo ""; } else { echo ""; } } else { echo ""; } } } function handleCreateFile($directory) { if (!empty($_POST['fileName'])) { $newFile = $directory . DIRECTORY_SEPARATOR . $_POST['fileName']; if (!file_exists($newFile)) { if (file_put_contents($newFile, '') !== false) { echo ""; } else { echo ""; } } else { echo ""; } } } function handleEditFile($filePath) { if (isset($_POST['content'])) { file_put_contents($filePath, $_POST['content']); echo ""; } $content = htmlspecialchars(file_get_contents($filePath)); echo "
"; } function handleDeleteFile($filePath) { if (file_exists($filePath)) { unlink($filePath); echo ""; } } function handleRenameFile($filePath) { if (!empty($_POST['newName'])) { $newPath = dirname($filePath) . DIRECTORY_SEPARATOR . $_POST['newName']; if (rename($filePath, $newPath)) { echo ""; } else { echo ""; } } else { echo ""; } } function displayDirectory($directory) { $files = array_diff(scandir($directory), array('.', '..')); echo "当前目录: $currentDir
"; echo ""; if (isset($_GET['action'])) { $filePath = $currentDir . DIRECTORY_SEPARATOR . $_GET['file']; handleFileActions($filePath); } displayDirectory($currentDir); echo "