mirror of https://github.com/sveltejs/svelte
commit
e63f9c000b
@ -0,0 +1,37 @@
|
|||||||
|
<script>
|
||||||
|
let 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);
|
||||||
|
|
||||||
|
for (const file of files) {
|
||||||
|
console.log(`${file.name}: ${file.size} bytes`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<label for="avatar">Upload a picture:</label>
|
||||||
|
<input
|
||||||
|
accept="image/png, image/jpeg"
|
||||||
|
bind:files
|
||||||
|
id="avatar"
|
||||||
|
name="avatar"
|
||||||
|
type="file"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<label for="many">Upload multiple files of any type:</label>
|
||||||
|
<input
|
||||||
|
bind:files
|
||||||
|
id="many"
|
||||||
|
multiple
|
||||||
|
type="file"
|
||||||
|
/>
|
||||||
|
|
||||||
|
{#if files}
|
||||||
|
<h2>Selected files:</h2>
|
||||||
|
{#each Array.from(files) as file}
|
||||||
|
<p>{file.name} ({file.size} bytes) </p>
|
||||||
|
{/each}
|
||||||
|
{/if}
|
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"title": "File inputs"
|
||||||
|
}
|
After Width: | Height: | Size: 2.7 KiB |
@ -0,0 +1,5 @@
|
|||||||
|
export default {
|
||||||
|
html: `
|
||||||
|
<h1>Hello world!</h1>
|
||||||
|
`,
|
||||||
|
};
|
@ -0,0 +1,6 @@
|
|||||||
|
<script>
|
||||||
|
$: user = {};
|
||||||
|
$: user.name = 'world';
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<h1>Hello {user.name}!</h1>
|
Loading…
Reference in new issue