Reputation: 41
<input type="text" class="input" placeholder="Path to folder.">
<div class="box" id="choose-btn" onclick="chooseFolder()">...</div>
<div class="accept">Patch</div>
let fdialog = require('nw-dialog');
function chooseFolder() {
fdialog.folderBrowserDialog(".exe", function(result) {
document.getElementsByClassName('input').innerHTML = result;
})
}
I want to select a folder with "#choose-btn"
,
the selected folder must be displayed in ".input"
,
if I click on Patch ".accept"
a file should be downloaded via link in the directory.
Upvotes: 1
Views: 670
Reputation: 715
Use Electron's native dialog box to choose the directory
let { dialog } = require('electron').remote;
function chooseFolder() {
dir = dialog.showOpenDialog({
properties: ['openDirectory']
}, function(res){
document.getElementsByClassName('input')[0].value = res[0];
});
}
Upvotes: 2