FormData.set()
The set() method of the FormData interface sets a new value for an existing key inside a FormData object, or adds the key/value if it does not already exist.
The difference between set() and append() is that if the specified key already exists, set() overwrites all existing values with the new one, whereas append() appends the new value onto the end of the existing values.
Syntax
set(name, value)
set(name, value, filename)
Parameters
name- : The name of the field whose data is contained in
value.
- : The name of the field whose data is contained in
value- : The value of the field. This can be a string or a
Blob(including subclasses such asFile). If none of these, the value is converted to a string.
- : The value of the field. This can be a string or a
filenameoptional- : The filename reported to the server when a
BloborFileis passed as the second parameter. The default filename forBlobobjects is "blob". The default filename forFileobjects is the file's filename.
- : The filename reported to the server when a
Return value
undefined