WebPageFileUpload Function

Action

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 WebPagePost, 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>";

Example

Upload of file c:\test.txt

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";

Include file

WebAPI.bdh

Syntax

WebPageFileUpload( in sUrl     : string,
                   in formBody : form,
                   in sTimer   : string optional,
                   in formUrl  : form optional ) : boolean;

Return value

  • 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.
sTimer Name of the timer used for page measurements (optional). If this parameter is omitted, no measurements are performed.
formUrl Form identifier used in the dclform section (optional). The expanded form is added to the URL after the "?".

Example

dcltrans
  transaction TWebPageFileUpload
  begin
    WebPageFileUpload("http://standardhost/data2html.asp",
                      FILE_UPLOAD_FORM);
  end TWebPageFileUpload;

dclform
  FILE_UPLOAD_FORM:
    "anyname"  := "anyvalue",
    "filename" := "my_file;"
                  "C:\\temp\\test.doc;application/msword";