ora/src/dashboard/components/FileUpload.svelte

29 lines
490 B
Svelte
Raw Normal View History

2020-10-11 23:46:06 +02:00
<script>
let text = 'Select File'
2021-11-23 01:45:19 +01:00
export let file
2020-10-11 23:46:06 +02:00
let input
function validate() {
if (!input || !input.files.length) return
2021-11-23 01:45:19 +01:00
file = input.files[0]
2020-10-11 23:46:06 +02:00
text = file.name
}
</script>
2021-11-22 01:58:09 +01:00
<label class="btn">
2021-11-23 01:45:19 +01:00
{text}
2021-11-22 01:58:09 +01:00
<input bind:this={input} on:change={validate} class="input" accept="application/json" type="file" />
</label>
2020-10-11 23:46:06 +02:00
<style>
label {
width: 18em;
max-width: 100%;
display: inline-block;
}
label input[type='file'] {
display: none;
}
</style>