I have pasted @Ha-Steve s UI upload button into my flow.
How can I also retrieve the name of the selected file?
This is the UI template code:
<body>
<button class="md-raised md-button md-ink-ripple" onclick="importData()">Upload</button>
<script>
let restoreScope = scope;
function importData() {
let input = document.createElement('input');
input.type = 'file';
input.id = 'restoreBtn';
input.onchange = _ => {
// you can use this method to get file and perform respective operations
let fReader = new FileReader();
fReader.readAsText(input.files[0]);
fReader.onloadend = function(event){
restoreScope.send({payload:event.target.result}});}
};
input.click();
}
</script>
</body>
<body>
<button class="md-raised md-button md-ink-ripple" onclick="importData()">Upload</button>
<script>
let restoreScope = scope;
function importData() {
let input = document.createElement('input');
input.type = 'file';
input.id = 'restoreBtn';
input.onchange = _ => {
// you can use this method to get file and perform respective operations
let fReader = new FileReader();
fReader.readAsText(input.files[0]);
fReader.onloadend = function(event){
restoreScope.send()
}
}
input.click();
}
</script>
</body>
<body>
<button class="md-raised md-button md-ink-ripple" onclick="importData()">Upload</button>
<script>
let restoreScope = scope;
function importData() {
let input = document.createElement('input');
input.type = 'file';
input.id = 'restoreBtn';
input.onchange = _ => {
// you can use this method to get file and perform respective operations
let fReader = new FileReader();
fReader.readAsText(input.files[0]);
fReader.onloadend = function(event){
restoreScope.send({'payload':event.target.result, 'name':input.files[0].name})
}
}
input.click();
}
</script>
</body>