I started a new project in plain html javascript, jquery, css, and Electron.
While learning about some of the nice offerings available to make desktop apps with these things, I found WebKitDirectory which in the plain app allows me to prompt the user for a directory with a file input, and get the full path.
Now I’m doing the exact same code in Meteor, and I get ‘undefined’ for the file path.
Is there something special I need to do in meteor to get this to work properly? As far as I know, webkitdirectory is not anything specific to Electron.
Here’s my code for reference in the electron app.
<div class="row">
<div class="column">
<div id="selectSource">
<input type="file" name="folderName" id="folderName" class="inputfile" webkitdirectory />
<label for="folderName"><i class="fa fa-folder-open-o"></i> Select a Source Directory</label>
</div>
</div>
<div class="column">
<input type="text" id="sourceDirPath" class="myInput" />
</div>
</div>
And the JS that goes with it
$("#folderName").change(function() {
var sourceVal = document.getElementById("folderName").files[0].path;
$("#sourceDirPath").val(sourceVal);
});
the above gives me the proper full folder / directory path and I can do what i need to with it.
The below is the code I have in Meteor.
<template name="syncSourceInput">
<div class="row">
<div class="column">
<div id="selectSource">
<input type="file" name="folderName" id="folderName" class="inputfile" webkitdirectory />
<label for="folderName"><i class="fa fa-folder-open-o"></i> Select a Source Directory</label>
</div>
</div>
<div class="column">
<input type="text" id="sourceDirPath" class="myInput" />
</div>
</div>
</template>
and the template event code is
Template.syncSourceInput.events({
'change #folderName': function() {
console.log("Source Changed");
var sourceVal = document.getElementById("folderName").files[0].path;
console.log("Source Path: " + sourceVal)
$("#sourceDirPath").val(sourceVal);
},
});
Any help with this is greatly appreciated, as always.