浏览器中读取本地电脑文件夹并进行新建删除重命名编辑文件等操作示例代码
代码语言:html
所属分类:其他
代码描述:浏览器中读取本地电脑文件夹并进行新建删除重命名编辑文件等操作示例代码,第一次选择本地文件夹后,下次刷新自动加载本地文件夹目录树,可折叠目录,在浏览器上像操作本地电脑一样操作目录,适合chrome和edge及firefox等现代浏览器,只要支持window.showDirectoryPicker就行。
代码标签: 浏览器 读取 本地 电脑 文件夹 进行 新建 删除 重命名 编辑 文件 操作 示例 代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>File Explorer</title> <link type="text/css" rel="stylesheet" href="//repo.bfw.wiki/bfwrepo/css/bootstrap.5.1.2.css"> <link type="text/css" rel="stylesheet" href="//repo.bfw.wiki/bfwrepo/css/all.6.0.css"> <style> .directory-tree { max-height: 100vh; overflow-y: auto; } .file-item, .folder-item { cursor: pointer; } .file-item:hover, .folder-item:hover { background-color: #f8f9fa; } .item-name { display: inline-block; min-width: 150px; } .context-menu { position: absolute; z-index: 1000; background-color: #fff; border: 1px solid #ccc; border-radius: 4px; padding: 5px 0; box-shadow: 0 2px 5px rgba(0,0,0,0.1); } .context-menu-item { padding: 5px 20px; cursor: pointer; } .context-menu-item:hover { background-color: #f8f9fa; } </style> </head> <body> <div class="container-fluid"> <div class="row"> <div class="col-md-3 directory-tree p-3 border-end"> <h3>本地文件管理器</h3> <div id="currentPath" class="mb-3"></div> <div class="mb-3"> <button id="openDirectory" class="btn btn-primary me-2">打开本地文件夹</button> </div> <div id="directoryTree"></div> </div> <div class="col-md-9 p-3"> <h3>文件编辑器,不要在iframe内打开</h3> <div id="currentFilePath" class="mb-2"></div> <div id="fileEditor"> <textarea id="fileCo.........完整代码请登录后点击上方下载按钮下载查看
网友评论0