Skip to main content
Version: v6.5.0

Upload file

Command Description

HTTP.UploadFile post upload file

Command Prototype

sRet = HTTP.UploadFile(url, file_path, data, headers, cookies, cert, timeout)

Command parameter

parametermandatorytypedefault valueInstructions
urlTruestring""Request URL
file_pathTruestring""File path, only supports passing in a single file, supports passing in two types of values, one is a string and the other is a dictionary; When a string is passed in, that is, the file path, the file name requested is "file"; When used as a dictionary, the format is {"path": "C: \ A. txt", "name": "XX"}, representing the file path and the file name specified at the time of the request
dataFalseexpression{}Request body data, upload file with additional data, which can be a string or dictionary
headersFalseexpression{}Request Header
cookiesFalseexpression{}Request cookie
certFalseexpression{}If the certificate, dictionary type, certificate path, and key are all empty, the authentication will be ignored. If there is no key, the key can be left blank
timeoutFalsenumber0Timeout (milliseconds)

Return result

SRet, Assign the result of running the command to this variable.

Run instance

/**************************Upload file**************************
Command prototype:
sRet = HTTP.UploadFile(url, file_path, data, headers, cookies, cert, timeout)
Input parameters:
url -- Link address. Note: Link address of the Post page.
file_path -- File path. Note: File path.
data -- Request body data. Note: Request body data.
headers -- Request headers. Note: Request headers.
cookies -- Request cookies. Note: Request cookies.
cert -- Client certificate. Note: Client certificate.
timeout -- Timeout (in milliseconds). Note: Timeout (in milliseconds).
Output parameters:
sRet -- The variable where the output of the function call is saved.
Notes:
None
******************************************************************/

Dim sRet = ""
sRet = HTTP.UploadFile("http://upload.example.com", "c:\test.txt", {}, {}, {}, "", 60000)
TracePrint(sRet)