form:AddFiles(name, table)
form:AddFiles()
is used to append multiple file upload sections when building a multipart/formdata HTTP POST
(sometimes referred to as RFC 2388-style posts). Once you've added all the sections you want included,
pass the form handle as parameter to #CURLOPT_HTTPPOST
. See easy:SetOpt_HTTPPost for details.
You must call form:Free() after the form post has been done to free the resources.
Using POST with HTTP 1.1 implies the use of a "Expect: 100-continue" header. You can disable this header
with #CURLOPT_HTTPHEADER
as usual.
First, there are some basics you need to understand about multipart/formdata posts. Each part consists of
at least a NAME
and a CONTENTS
part. If the part is made for file upload, there are also a stored
CONTENT-TYPE
and a FILENAME
. Below, we'll discuss what options you use to get these properties
in the parts you want to add to your post.
The name
argument must be a string which provides the name of this part. The name is not allowed to contain
zero-valued bytes.
The table
argument must contain a table describing a list of files to be added to the form post object.
There must be one item per file in the table. The individual table items can be of three different types: