ReceiveHTTPFile()

Syntax

Result = ReceiveHTTPFile(URL$, Filename$ [, Flags [, UserAgent$]])
Description
Download a file to disk from the given URL$.

Parameters

URL$ The URL to download from.
Filename$ The local filename to write the file to. If the filename does not include a full path, it is interpreted relative to the current directory. If the file exists, it will be overwritten.
Flags (optional) It can be a combination of the following value:
  #PB_HTTP_Asynchronous: starts the download asynchronously.
  #PB_HTTP_NoRedirect  : don't follow automatic redirections.
UserAgent$ (optional) Change the user agent for the HTTP request. Default user agent is set to "Mozilla/5.0 Gecko/41.0 Firefox/41.0" for maximum compatibility.

Return value

Returns nonzero if the download was successful, zero otherwise. If #PB_HTTP_Asynchronous was specified, it returns the 'HttpConnection' value needed for HTTPProgress(), AbortHTTP() and FinishHTTP().

Remarks

InitNetwork() has to be called before using this command.

On Linux, 'libcurl' needs to be installed to have this command working (most of Linux distributions comes with it already installed).

Example

  InitNetwork()

  Filename$ = SaveFileRequester("Where to save index.php ?", "", "", 0)

  If ReceiveHTTPFile("http://www.purebasic.com/index.php", Filename$)
    Debug "Success"
  Else
    Debug "Failed"
  EndIf

See Also

GetHTTPHeader(), URLEncoder()

Supported OS

All

<- HTTPProxy() - Http Index - ReceiveHTTPMemory() ->