Open lionel-rowe opened 3 months ago
Observed browser behavior looks to be correct per the spec:
- Otherwise, if the field element is an input element whose type attribute is in the File Upload state, then:
- If there are no selected files, then create an entry with name and a new File object with an empty name, application/octet-stream as type, and an empty body, and append it to entry list.
Meanwhile, the raw HTTP request body looks something like this:
------WebKitFormBoundary5jMC0I81oPK5c8nU
Content-Disposition: form-data; name="files"; filename=""
Content-Type: application/octet-stream
------WebKitFormBoundary5jMC0I81oPK5c8nU--
Version: Deno 1.45.5
Given the following HTML:
Assuming no files are selected, calling
FormData#get('files')
on aFormData
object constructed from this form on the client side (tested latest Chrome, FireFox) gives an emptyFile
object. However, calling(await req.formData()).get('files')
on theRequest
given byDeno.serve
gives an empty string""
instead.Notably,
FormData#getAll('files')
gives an array of length 1 in both Deno and browsers, which hopefully everyone can agree is a horrible way of representing zero files, but the content of that array's element differs (again, it's an empty file on client side vs an empty string on Deno).Repro: https://dash.deno.com/projects/formdata-no-files-repro