Discuss this help topic in SecureBlackbox Forum

TElHTTPSClient.PostWebForm

TElHTTPSClient     See also     


Filter: C#  VB.NET  Pascal  C++  PHP  Java  


Sends the POST request to server.

Declaration

[C#]
    int PostWebForm(string URL, TElStringList Fields, string FileField, string FileName, System.IO.Stream FileStream, string ContentType, bool CloseStream);
    int PostWebForm(string URL, TElStringList Fields, string FileField, string FileName, System.IO.Stream FileStream, string ContentType, bool CloseStream, string Charset);

[VB.NET]
    Function PostWebForm(ByVal URL As String, ByVal Fields As TElStringList, ByVal FileField As String, ByVal FileName As String, ByVal FileStream As System.IO.Stream, ByVal ContentType As String, ByVal CloseStream As Boolean) As Integer
    Function PostWebForm(ByVal URL As String, ByVal Fields As TElStringList, ByVal FileField As String, ByVal FileName As String, ByVal FileStream As System.IO.Stream, ByVal ContentType As String, ByVal CloseStream As Boolean, ByVal Charset As String) As Integer

[Pascal]
    function PostWebForm(const URL : string; Fields : TElStringList; const FileField : string = ''; const FileName : string = ''; FileStream : TStream = nil; ContentType : string = ''; CloseStream : Boolean = false) : integer; overload;
    function PostWebForm(const URL : string; Fields : TElStringList; const FileField : string; const FileName : string; FileStream : TStream; ContentType : string; CloseStream : Boolean; const Charset : string) : integer; overload;

[C++]
    int32_t PostWebForm(const std::string &URL, TElStringList &Fields, const std::string &FileField, const std::string &FileName, TStream &FileStream, const std::string &ContentType, bool CloseStream);
    int32_t PostWebForm(const std::string &URL, TElStringList *Fields, const std::string &FileField, const std::string &FileName, TStream *FileStream, const std::string &ContentType, bool CloseStream);
    int32_t PostWebForm(const std::string &URL, TElStringList &Fields, const std::string &FileField, const std::string &FileName, TStream &FileStream, const std::string &ContentType, bool CloseStream, const std::string &Charset);
    int32_t PostWebForm(const std::string &URL, TElStringList *Fields, const std::string &FileField, const std::string &FileName, TStream *FileStream, const std::string &ContentType, bool CloseStream, const std::string &Charset);

[PHP]
    integer PostWebForm(string $URL, TElStringList $Fields, string $FileField, string $FileName, TStream $FileStream, string $ContentType, bool $CloseStream)
    integer PostWebForm(string $URL, TElStringList $Fields, string $FileField, string $FileName, TStream $FileStream, string $ContentType, bool $CloseStream, string $Charset)

[Java]
    int postWebForm(String URL, TElStringList Fields, String FileField, String FileName, TElStream FileStream, String ContentType, boolean CloseStream);
    int postWebForm(String URL, TElStringList Fields, String FileField, String FileName, TElStream FileStream, String ContentType, boolean CloseStream, String Charset);

Parameters

  • URL - specifies resource address. This method does NOT encode the parameters that you pass in the URL, they need to be encoded prior to calling the method.
  • Fields - request parameters and their values fields
  • FileField - name of the parameter corresponding to the uploaded file. Default value is empty string.
  • FileName - name of the file to be sent. Default value is empty string.
  • FileStream (Stream) - stream with file data. Default value is null.
  • ContentType - file data type (e.g. text/plain). Default value is empty string.
  • CloseStream - specifies if FileStream object should be freed after request execution. Default value is False.
  • Charset -

Return value

    HTTP result code

Description

Use this method to send 'POST' request to server. POST method is used to transfer data to remote resource.

Content parameter (where present) should contain the data to be sent to the server as-is. You can use this parameter to send the pre-formatted form or the stream of data etc.

The variant of the method with Fields and FileField properties lets you submit a form (as you do in browsers) with optional file attachment.
Fields is the list of form field names and values in the form of "Name=Value" in each line. This list can be empty.
FileField contains the name of the field, which stands for attached file (when you look in HTML form source code).
FileName is the name of the file as the server will see it.
FileStream is contents of the submitted file. This is an optional parameter.
ContentType parameter lets you override the default content type. If FileStream is specified, then ContentType is an attribute of the file (default value is "application/octet-stream"). If FileStream is not specified, then ContentType is an attribute of the form (default value is "application/x-www-form-urlencoded").

The variant of the method with only URL parameter lets you stream the data dynamically via OnHTTPDynamicDataNeeded event. Note that not all servers support such streaming.

To POST/PUT several streams you can use TElMultiStream class: create an instance of this class, add the streams to the TElMultiStream object using AddStream method, and pass the instance of TElMultiStream to Post/Put method.

See also:     Delete     Post     Put     Get     Options     Trace     Head     OnDynamicDataNeeded     TElMultiStream    

Discuss this help topic in SecureBlackbox Forum