Because when making a request encoded as multipart/form-data (which is a requirement for file uploads) all you can send is a flat list of name=value pairs - where value may either be a string or a file.
If you try to add an array or an object directly to the FormData object, it will be implicitly converted to a string, which is probably not what you want (resulting in, for example, "[object Object]" or "12,15,28,55").
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hello Diogo,
Why is that?
Because when making a request encoded as
multipart/form-data
(which is a requirement for file uploads) all you can send is a flat list ofname=value
pairs - wherevalue
may either be a string or a file.If you try to add an array or an object directly to the
FormData
object, it will be implicitly converted to a string, which is probably not what you want (resulting in, for example,"[object Object]"
or"12,15,28,55"
).