WebPageSubmitFile Function


Queries the currently active page for the specified HTML form. If this form is found, the function submits the form to the Web server by means of the HTTP POST method and reads the response page. If the retrieved document is of content type HTML, it is parsed and embedded documents are requested.

This function is used when the form submission uses an encoding format different to ‘application/x-www-form-urlencoded’. Most common cases are file uploads which use content-type ‘multipart/form-data’. Note that the default value pairs of the HTML form are not automatically used for submission. The body message has to be supplied as a whole.

Form identification rules are listed herein, ordered by priority:

  • HTML forms to be queried are identified by a name:

    <form name="form1" action="data2html.asp">
      <input type=hidden name="cantfind" value="#b21334a45">
      <input type=text name=ShoeSize value=44>
  • The “value” attribute of the submit button:

    <form name="form1" action="data2html.asp">
      <input type="submit" value=Insert>
  • The image used for submission may provide an “alt” attribute:

    <form name="form1" action="data2html.asp">
      <input type="image" src=box5.gif alt="PostBox">

In the case of changing HTML form name, you can refer to the HTML form by number. All forms are numbered sequentially throughout the Web page.

Include file



WebPageSubmitFile( in sHtmlForm : string allownull,
                   in sFile     : string,
                   in sContent  : string optional,
                   in sTimer    : string optional,
                   in nFormNo   : number optional,
                   in sFrame    : string optional,
                   in hContext  : number optional): boolean;

Return value

  • true if the form is found and submitted successfully

  • false otherwise

Parameter Description
sHtmlForm The name of the HTML form to search for in the currently active Web page, or if the hContext parameter is not omitted in the specified context. Set this parameter to NULL if a name is not available or if you want to identify the HTML form only by its number.
sFile File to post to the server.
sContent Content type string used in the request, for example, "image/gif" (optional).
sTimer Name of the timer used for page measurements (optional). If this parameter is omitted, no measurements are performed.
nFormNo Number of the Web form in the Web page (optional). If sHtmlForm is NULL, the number specifies the n-th form in the page. If sHtmlForm specifies a name, the number specifies the n-th form with the given name.
sFrame The name of the frame the document is assigned to (optional). If this parameter is provided, the form is searched only within this frame document.
hContext Context, stored by a prior call of the WebPageStoreContext function, where to search the form (optional). If this parameter is omitted the form is searched for in the actual page and all stored contexts.


  transaction TMain
    sFile: string;
    sFile := "c:\\temp\\dummyfile.txt";
    WebPageUrl("http://lab1/", "Silk Performer Test Site");
    WebPageLink("File Upload Samples",
                "SA-FileUp Samples - Main Page");
    WebPageLink("Simple", "Simple Upload Example");
    WebPageSubmitFile("Upload File", sFile);
  end TMain;