forgot one

This commit is contained in:
James Shiffer 2020-07-06 07:57:55 -07:00
parent a9d2b49456
commit 8ba12e5eca
No known key found for this signature in database
GPG Key ID: C0DB8774A1B3BA45

View File

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