Ir para o conteúdo principal

File Object

Use a API do HTML5 File para funcionar nativamente com arquivos no sistema de arquivos.

Warning The path property that Electron adds to the File interface is deprecated and will be removed in a future Electron release. We recommend you use webUtils.getPathForFile instead.

The DOM's File interface provides abstraction around native files in order to let users work on native files directly with the HTML5 file API. Electron has added a path attribute to the File interface which exposes the file's real path on filesystem.

Example of getting a real path from a dragged-onto-the-app file:

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

<script>
document.addEventListener('drop', (e) => {
e.preventDefault();
e.stopPropagation();

for (const f of e.dataTransfer.files) {
console.log('File(s) you dragged here: ', f.path)
}
});
document.addEventListener('dragover', (e) => {
e.preventDefault();
e.stopPropagation();
});
</script>