]> khamidou — GitHub mirrors - electron.git/commitdiff
add doc translation for file object
authorJohn-Lin <linton.tw@gmail.com>
Tue, 8 Sep 2015 07:46:48 +0000 (15:46 +0800)
committerJohn-Lin <linton.tw@gmail.com>
Tue, 8 Sep 2015 07:46:48 +0000 (15:46 +0800)
docs-translations/zh-TW/api/file-object.md [new file with mode: 0644]

diff --git a/docs-translations/zh-TW/api/file-object.md b/docs-translations/zh-TW/api/file-object.md
new file mode 100644 (file)
index 0000000..4f523c4
--- /dev/null
@@ -0,0 +1,28 @@
+# `File` object
+
+DOM's File 介面提供一個將本地文件抽象化,並可以讓使用者對本地文件直接使用 HTML5 檔案 API
+Electron 可以添加一個 `path` 屬性至 `File` 接口進而顯示檔案在檔案系統內的真實路徑。
+
+範例,獲得一個檔案之真實路徑,將檔案拖拉至應用程式 (dragged-onto-the-app):
+
+```html
+<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>
+```