Posts the content of a Web form, including specified files, to the Web server by means of the HTTP POST method. This function implements a RFC1867-compliant file upload function for form-based file upload in HTML.
This is a mapping to WebUrlPostBin, and uses a form specified in the dclform section to construct the data to post to the server.
The form consists of name-value pairs as usual, only the files to upload need a minor modification: a file to upload needs to be specified by a name-value pair in the following way:
"filename" := "<name of the input tag>;<file name>;<content type>";
HTML code:
<form enctype="multipart/form-data" action="data2html.asp" method=post> <input type="text" name="anyname" value="anyvalue"> <input size="32" name="my_file" type="file"> <input type="submit" value="Upload"> </form>
BDL form:
"anyname" := "anyvalue", "filename" := "my_file;C:\\test.txt;plain/text";
WebAPI.bdh
WebFileUpload( in sUrl : string, in formBody : form, in fWait : float optional ): boolean;
true if successful
false otherwise
Parameter | Description |
---|---|
sUrl | Complete URL to the file on the server |
formBody | Form identifier used in the dclform section (see example below). The expanded form is added to the body of the request. The Content-Length is added automatically. The Content-Type is multipart/form-data. |
fWait | Minimum time or minimum mean time that this function call has to last (optional). Default value is 0.0 |
dcltrans transaction TWebFileUpload begin WebFileUpload("http://standardhost/data2html.asp", FILE_UPLOAD_FORM); end TWebFileUpload; dclform FILE_UPLOAD_FORM: "anyname" := "anyvalue", "filename" := "my_file;C:\\temp\\test.doc;application/msword";