<form enctype=multipart/form-data>
is needed for files, but use:enhance
masks it
#9819
Labels
breaking change
bug
Something isn't working
low hanging fruit
ready to implement
please submit PRs for these issues!
Describe the bug
If you have a form like this...
...then submitting the form will work correctly under normal conditions — the action will receive a
FormData
object with afile
value of typeFile
:If you disable JavaScript, it works differently —
data.get('file')
will be astring
(the file's name) instead of aFile
object. This is because the form needsenctype="multipart/form-data"
.I'm not exactly sure what we should do here. If we explicitly set the
content-type
toform.enctype
when we submit the form insideenhance
, we still get different behaviour —file
will benull
for a JS submission but will still be astring
for a no-JS submission. This platform really is an absolute clusterfuck.I think the best thing to do is probably to print a warning in dev mode if the
FormData
object includes files andform.enctype !== 'multipart/form-data'
. For SvelteKit 2 we could upgrade that to an error, but for now it would be a breaking change that is probably unwise.Reproduction
later when I'm less busy
Logs
No response
System Info
Severity
annoyance
Additional Information
No response
The text was updated successfully, but these errors were encountered: