forgot one
This commit is contained in:
parent
a9d2b49456
commit
8ba12e5eca
@ -18,7 +18,7 @@
|
|||||||
const { session } = stores();
|
const { session } = stores();
|
||||||
|
|
||||||
let editor, form, uploadForm;
|
let editor, form, uploadForm;
|
||||||
let loading = false;
|
let loading = false, loadingAttach = false;
|
||||||
let title = '', category = '';
|
let title = '', category = '';
|
||||||
export let categories;
|
export let categories;
|
||||||
|
|
||||||
@ -112,6 +112,8 @@
|
|||||||
async function upload()
|
async function upload()
|
||||||
{
|
{
|
||||||
let fd = new FormData(uploadForm);
|
let fd = new FormData(uploadForm);
|
||||||
|
loadingAttach = true;
|
||||||
|
try {
|
||||||
const res = await fetch(`/cms/upload`, {
|
const res = await fetch(`/cms/upload`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
@ -135,6 +137,11 @@
|
|||||||
} else {
|
} else {
|
||||||
alert(`Error ${res.status}: ${json.message}`);
|
alert(`Error ${res.status}: ${json.message}`);
|
||||||
}
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.error(err);
|
||||||
|
} finally {
|
||||||
|
loadingAttach = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@ -169,6 +176,9 @@
|
|||||||
<form enctype="multipart/form-data" action="/cms/upload" method="POST" bind:this={uploadForm}>
|
<form enctype="multipart/form-data" action="/cms/upload" method="POST" bind:this={uploadForm}>
|
||||||
<p>Add Image to Article:
|
<p>Add Image to Article:
|
||||||
<input type="file" name="upload" accept="image/*"> <button on:click|preventDefault={upload}>Upload</button>
|
<input type="file" name="upload" accept="image/*"> <button on:click|preventDefault={upload}>Upload</button>
|
||||||
|
{#if loadingAttach}
|
||||||
|
<progress>Uploading...</progress>
|
||||||
|
{/if}
|
||||||
</p>
|
</p>
|
||||||
</form>
|
</form>
|
||||||
<button on:click={submit}>Submit</button>
|
<button on:click={submit}>Submit</button>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user