node.jselectron

Electron: get full path of uploaded file


I'm buildind now GUI using Electron. (like PhoneGap for desktop apps)

Is there a way to enable full path for file checked in <input type="file">?
Insted of C:\fakepath\dataset.zip now. (the directory name isn't "fakepath", but that is the value of document.getElementById("myFile").value)

Or, is there other way to select a file?


Solution

  • Electron adds a path property to File objects, so you can get the real path from the input element using:

    document.getElementById("myFile").files[0].path