# 24.1. `File` 對象
> 使用 HTML5 的 `File` API 跟文件系統的文件原生工作
DOM 的 File 接口提供了對本地文件的抽象,以使用戶直接使用 HTML5 文件 API 操作原生文件。Electron 已經添加了一個 `path` 屬性到 `File` 接口,暴露文件在文件系統中的真實路徑。
關于從一個拖動到應用中的文件獲得真實路徑的例子:
```html
<div id="holder">
Drag your file here
</div>
<script>
const holder = document.getElementById('holder')
holder.ondragover = () => {
return false;
}
holder.ondragleave = holder.ondragend = () => {
return false;
}
holder.ondrop = (e) => {
e.preventDefault()
for (let f of e.dataTransfer.files) {
console.log('File(s) you dragged here: ', f.path)
}
return false;
}
</script>
```
- 索引
- 前言.關于Electron
- 第一部分 開發指南
- 第1章.平臺支持
- 第2章.安全、原生功能和你的責任
- 第3章.版本說明
- 第4章.發行應用
- 第5章.Mac App商店提交指南
- 第6章.Windows商店指南
- 第7章.應用打包
- 第8章.使用Node原生模塊
- 第9章.調試主進程
- 9.1.在VSCode中調試
- 9.2.在node-inspector中調試
- 第10章.使用Selenium和WebDriver
- 第11章.DevTools擴展
- 第12章.使用Pepper Flash插件
- 第13章.使用Widevine CDM插件
- 第14章.通過自動化持續集成系統進行測試
- 第15章.離屏渲染
- 第二部分 使用教程
- 第16章.快速入門
- 第17章.桌面環境集成
- 第18章.在線/離線事件探測
- 第19章.應答式編譯器(REPL)
- 第三部分 API參考
- 第20章.API簡介
- 第21章.進程對象
- 第22章.Chrome的命令行開關
- 第23章.環境變量
- 第24章.定制的DOM元素
- 24.1.File 對象
- 24.2.webview 標簽
- 第25章.主進程模塊
- 25.1.app
- 25.2.BrowserWindow
- 25.3.無框架窗口
- 第26章.渲染進程模塊
- 第27章.兩種進程可用的模塊
- 第四部分 高級主題
- 附 FAQ
- 附 文檔規范
- 附 示例用例
- 1.無邊框窗口