feat: implement file upload functionality and create file serving endpoint
All checks were successful
Build Docker Image / build (push) Successful in 1m20s
All checks were successful
Build Docker Image / build (push) Successful in 1m20s
This commit is contained in:
@@ -30,6 +30,14 @@
|
||||
}, 3000);
|
||||
};
|
||||
|
||||
const handleFileSelect = (event: Event) => {
|
||||
const target = event.target as HTMLInputElement;
|
||||
if (target.files && target.files.length > 0) {
|
||||
// Clear pictureUrl when a file is selected
|
||||
editForm.pictureUrl = '';
|
||||
}
|
||||
};
|
||||
|
||||
const getFandomUrl = (url: string | null | undefined) => {
|
||||
if (!url) return null;
|
||||
if (url.startsWith('http://') || url.startsWith('https://')) return url;
|
||||
@@ -516,6 +524,7 @@
|
||||
class="mt-6 space-y-4"
|
||||
method="POST"
|
||||
action="?/update"
|
||||
enctype="multipart/form-data"
|
||||
use:enhance={() => {
|
||||
isSaving = true;
|
||||
return async ({ result }) => {
|
||||
@@ -776,10 +785,24 @@
|
||||
name="pictureUrl"
|
||||
bind:value={editForm.pictureUrl}
|
||||
placeholder={selectedChar?.pictureUrl || ''}
|
||||
class="w-full rounded-lg border border-gray-500 bg-slate-800 px-3 py-2 text-white placeholder:text-gray-400/40"
|
||||
class="w-full rounded-lg border border-gray-500 bg-slate-800 px-3 py-2 text-white placeholder:text-gray-400/40"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="char-picture-file" class="block text-sm font-medium text-gray-300 mb-2">Or Upload Picture</label>
|
||||
<input
|
||||
type="file"
|
||||
id="char-picture-file"
|
||||
name="pictureFile"
|
||||
accept="image/*"
|
||||
onchange={handleFileSelect}
|
||||
class="w-full rounded-lg border border-gray-500 bg-slate-800 px-3 py-2 text-white file:mr-4 file:py-2 file:px-4 file:rounded file:border-0 file:text-sm file:font-semibold file:bg-amber-600 file:text-white hover:file:bg-amber-700"
|
||||
/>
|
||||
<p class="mt-1 text-xs text-gray-400">File will be saved as {selectedChar?.id}.jpg/png/etc</p>
|
||||
</div>
|
||||
|
||||
|
||||
<div>
|
||||
<label for="char-url" class="block text-sm font-medium text-gray-300 mb-2">Fandom URL</label>
|
||||
<input
|
||||
|
||||
Reference in New Issue
Block a user