Skip to content

Formdata

A multipart/form-data implementation for luau.

This implementation is based on the following spec(s):

Properties

The Formdata instance has no set properties!

Methods

The Formdata instance has no set methods!

Functions

getBody

Formdata . getBody (

     self: FormData
)  -> ()

Not included in the spec, but we need this to be able to get the body for the formdata object.

getHeader

Formdata . getHeader (

     self: FormData
)  -> ()

Not included in the spec, but we need this to be able to get the header for the formdata object.

append

Formdata . append (

     self: FormData
     name: string
     value: string
     filename: string?
     encoding: string?
)  -> ()

Appends a new entry to the form data’s internal ‘entries’ table.

set

Formdata . set (

     self: FormData
     name: string
     value: string
     filename: string?
     encoding: string?
)  -> ()

Sets the name, value and filename of an entry in the form data’s internal ‘entries’ table.

Follows the standard found here: https://xhr.spec.whatwg.org/#dom-formdata-append

delete

Formdata . delete (

     self: FormData
     name: string
)  -> ()

Function responsible for the removal of a formdata entry from the formdata’s internal ‘entries’ table.

has

Formdata . has (

     self: FormData
     name: string
)  -> ()

Function responsible for checking if this formdata object has a specific entry.

get

Formdata . get (

     self: FormData
     name: string
)  -> ()

Function responsible for getting the value of a formdata entry from the formdata’s internal ‘entries’ table.

getAll

Formdata . getAll (

     self: FormData
     name: string?
)  -> ()

Function responsible for getting all the values of a formdata entry from the formdata’s internal ‘entries’ table.

If a name is provided, it will only return the values of all entries with the provided name.

new

Formdata . new ()  -> ()

Constructor for the FormData object.

This function is missing the form and submitter fields that are defined in the spec, but are not relevant for the implementation of this feature in luau.

parse

Formdata . parse (

     textSource: string
     mimeType: string
)  -> ()

Parses formdata a string into a FormData object.