forget-cancellare-vecchi-toot/components/ArchiveForm.html

39 lines
1.2 KiB
HTML
Raw Normal View History

<form action={action} method='post' enctype='multipart/form-data'>
{#if file_too_big}
<div class="banner warning">
<p>The file you have selected is very large.</p>
<p>Twitter has two types of archives, <b>Forget does not support
"Your Twitter data" archives, only "Tweet archives"</b>
available from
<a href="https://twitter.com/settings/account#export_request">your account settings</a>.
Please make sure you have the right type of archive.</p>
</div>
{/if}
<input type="file" name="file" accept="application/zip,.zip"
2019-05-02 00:47:44 +02:00
on:change={take_file(this.files)}>
<input type="submit" value="Upload">
<input type='hidden' name='csrf-token' value={csrf_token}>
</form>
<script>
2019-05-02 00:47:44 +02:00
export let csrf_token, action;
function get_file_size(file_list){
/* returns size of selected file given an <input type="file">
or 0 if no file is selected */
let size = 0;
for(let i = 0; i < file_list.length; i++){
size += file_list[i].size;
}
return size;
}
2019-05-02 00:47:44 +02:00
function take_file(file_list){
file_size: get_file_size(file_list);
}
2019-05-02 00:47:44 +02:00
let file_size = 0;
$: file_too_big = file_size > 10000000; // 10 MB
</script>