Components All New MacOS Windows Linux iOS
Examples Mac & Win Server Client Guides Statistic FMM Blog Deprecated Old

CURL.SetInputText

Sets input data for this transfer to be the text you provide.

Component Version macOS Windows Linux Server iOS SDK
CURL 2.5 ✅ Yes ✅ Yes ✅ Yes ✅ Yes ✅ Yes
MBS( "CURL.SetInputText"; curl; text { ; Encoding } )   More

Parameters

Parameter Description Example Flags
curl The CURL session handle. $curl
text The text to send.
Encoding The text encoding for text parameter.
Default is UTF-8 for version 10.0 or newer and native encoding before.

Can also be "hex" or "base64" to provide data encoded with hex or base64 algorithm.
Possible encoding names: ANSI, ISO-8859-1, Latin1, Mac, Native, UTF-8, DOS, Hex, Base64 or Windows. More listed in the FAQ.
"UTF-8" Optional

Result

Returns "OK" on success.

Description

Sets input data for this transfer to be the text you provide.
Also sets input file length. You need to define input data for file uploads, http posts and http put operations.
Please make sure you choose the text encoding the other side expects.
To avoid chunked transfer to the server, you can also use CURL.SetOptionPostFields instead for text input.
If you set CURL.SetOptionHTTPHeader with Transfer-Encoding and/or Expect, you can disable chunked transfer.

For HTTP POST, please use CURL.SetOptionPost with 1 and CURL.SetOptionPostFields with your POST content using web services and other things.

Using this function is not recommended for more than a few hundred MB of text. If you need more, better stream the data with CURL.OpenInputFile from a file.

Examples

Set Text:

MBS("CURL.SetInputText"; $curl; "Hello World"; "utf8")

Set Text and disable Transfer Encodings and Expect header:

MBS("CURL.SetInputText"; $curl; "Hello World")
MBS("CURL.SetOptionHTTPHeader"; $curl; "Transfer-Encoding:"; "Expect:")

FTP Upload some text into a file on server:

Set Variable [$curl; Value:MBS("CURL.New")]
Set Variable [$result; Value:MBS("CURL.SetOptionURL"; $curl; "ftp://test.test/test/hello.txt")]
Set Variable [$result; Value:MBS("CURL.SetOptionUpload"; $curl; 1)]
Set Variable [$result; Value:MBS("CURL.SetOptionPassword"; $curl; CURL Test::Password)]
Set Variable [$result; Value:MBS("CURL.SetOptionUserName"; $curl; CURL Test::Name)]
Set Variable [$result; Value:MBS("CURL.SetInputText"; $curl; "This is content to upload")]
Set Variable [$result; Value:MBS("CURL.SetOptionVerbose"; $curl; 1)]
Set Field [CURL Test::Result; MBS("CURL.Perform"; $curl)]
Set Field [CURL Test::debug; MBS("CURL.GetDebugMessages"; $curl)]
Set Variable [$result; Value:MBS("CURL.Release"; $curl)]

Upload empty file with SFTP:

Set Variable [ $curl ; Value: MBS("CURL.New") ]
Set Variable [ $result ; Value: MBS("CURL.SetOptionURL"; $curl; "sftp://127.0.0.1/Users/cs/Desktop/test.txt" ) ]
Set Variable [ $result ; Value: MBS("CURL.SetOptionUpload"; $curl; 1) ]
Set Variable [ $result ; Value: MBS("CURL.SetOptionPassword"; $curl; "secret") ]
Set Variable [ $result ; Value: MBS("CURL.SetOptionUserName"; $curl; "cs") ]
Set Variable [ $result ; Value: MBS( "CURL.SetOptionSSHAuthTypes"; $curl; 2+8 ) ]
Set Variable [ $result ; Value: MBS("CURL.SetInputText"; $curl; "") ]
Set Field [ CURL Test::Result ; MBS("CURL.Perform"; $curl) ]
Set Field [ CURL Test::debug ; MBS("CURL.GetDebugMessages"; $curl) ]
Set Variable [ $result ; Value: MBS("CURL.Release"; $curl) ]

Pass upload image as base64 encoded text:

MBS("CURL.SetInputText"; $curl; $ImageBase64; "base64")

Make a custom request sending some text:

Set Variable [$result; Value: MBS("CURL.SetOptionUpload"; $curl; 1)]
Set Variable [$result; Value: MBS("CURL.SetOptionCustomRequest"; $curl; "UPDATE")]
Set Variable [$result; Value: MBS("CURL.SetInputText"; $curl; $xml )]
Set Variable [$result; Value: MBS("CURL.SetOptionHTTPHeader"; $curl; "Content-Type: text/xml" )]

See also

Release notes

Example Databases

Blog Entries

This function checks for a license.

Created 18th August 2014, last changed 31st January 2023


CURL.SetInputPNG - CURL.SetMultiOptionChunkLengthPenaltySize