File对象

为了让用户能够通过HTML5的file API直接操作本地文件,DOM的File接口提供了对本地文件的抽象。Electron在File接口中增加了一个path属性,它是文件在系统中的真实路径。


获取拖动到APP中文件的真实路径的例子:

<div id="holder">
  Drag your file here
</div>

<script>
  var holder = document.getElementById('holder');
  holder.ondragover = function () {
    return false;
  };
  holder.ondragleave = holder.ondragend = function () {
    return false;
  };
  holder.ondrop = function (e) {
    e.preventDefault();
    var file = e.dataTransfer.files[0];
    console.log('File you dragged here is', file.path);
    return false;
  };
</script>

标签:Electron

相关阅读 >>

Electron 桌面环境集成

Electron autoupdater 模块

Electron 术语表

Electron dialog 模块

Electron ipcmain 模块

Electron 向mac app store 应用提交向导

Electron clipboard 模块

Electron locales

Electron 自动更新功能autoupdater

Electron 构建系统概览

更多相关阅读请进入《Electron》频道 >>