adjustments

pull/5141/head
Conduitry 5 years ago
parent aa616cba9b
commit 13e4b801e9

@ -544,11 +544,9 @@ Numeric input values are coerced; even though `input.value` is a string as far a
<input type="range" bind:value={num}> <input type="range" bind:value={num}>
``` ```
##### File input bindings
--- ---
On `<input>` elements with `type="file"`, you can use `bind:files` to get the [list of selected files](https://developer.mozilla.org/en-US/docs/Web/API/FileList). On `<input>` elements with `type="file"`, you can use `bind:files` to get the [`FileList` of selected files](https://developer.mozilla.org/en-US/docs/Web/API/FileList).
```sv ```sv
<label for="avatar">Upload a picture:</label> <label for="avatar">Upload a picture:</label>

@ -2,6 +2,8 @@
let files; let files;
$: if (files) { $: if (files) {
// Note that `files` is of type `FileList`, not an Array:
// https://developer.mozilla.org/en-US/docs/Web/API/FileList
console.log(files); console.log(files);
for (const file of files) { for (const file of files) {
@ -28,13 +30,8 @@
/> />
{#if files} {#if files}
<h2>Selected files:</h2> <h2>Selected files:</h2>
{#each Array.from(files) as file} {#each Array.from(files) as file}
<p>{file.name} ({file.size} bytes) </p> <p>{file.name} ({file.size} bytes) </p>
{/each} {/each}
{/if} {/if}
<!--
Note that `files` is of type `FileList`, not an Array:
https://developer.mozilla.org/en-US/docs/Web/API/FileList
-->
Loading…
Cancel
Save