# UrlDownloadToFile

Downloads a file from the Internet.

    UrlDownloadToFile, URL, Filename

### Parameters

URL | URL of the file to download. For example, http://someorg.org might retrieve the welcome page for that organization.
Filename | Download to a file: Specify the name of the file to be created locally, which is assumed to be in %A_WorkingDir% if an absolute path isn't specified. Any existing file will be overwritten by the new file. Download to a variable: There is callable function you can copy and paste into your script at www.autohotkey.com/forum/topic10466.html.

### ErrorLevel

[v1.1.04+] This command is able to throw an exception on failure. For more information, see Runtime Errors.

ErrorLevel is set to 1 if there was a problem or 0 otherwise.

### Remarks

The download might appear to succeed even when the remote file doesn't exist. This is because many web servers send an error page instead of the missing file. This error page is what will be saved in place of Filename.

Internet Explorer 3 or greater must be installed for this function to work. Firewalls or the presence of multiple network adapters may cause this function to fail. Also, some websites may block such downloads.

Caching:

- In v1.0.44.07+, the URL is retrieved directly from the remote server (that is, never from Internet Explorer's cache). To permit caching, precede the URL with *0 followed by a space; for example: *0 http://someorg.org. The zero following the asterisk may be replaced by any valid dwFlags number; for details, search www.microsoft.com for InternetOpenUrl.
- In versions older than 1.0.44.07, the file is retrieved from the cache whenever possible. To avoid this, specify a query string at the end of the URL. For example: http://www.someorg.org/doc.html?fakeParam=42. Note: If you download the same file frequently, the query string should be varied.

Proxies: UrlDownloadToFile will use a proxy server to access the Internet if such a proxy has been configured in Microsoft Internet Explorer's settings.

FTP and Gopher: v1.0.48.04+ supports FTP and Gopher URLs. For example:

    UrlDownloadToFile, ftp://example.com/home/My File.zip, C:\My Folder\My File.zip  ; Log in anonymously.
    UrlDownloadToFile, ftp://user:pass@example.com:21/home/My File.zip, C:\My Folder\My File.zip  ; Log in as a specific user.
    UrlDownloadToFile, ftp://user:pass@example.com/My Directory, C:\Dir Listing.html  ; Gets a directory listing in HTML format.

### Related

FileRead, FileCopy

### Examples

    UrlDownloadToFile, http://l.autohotkey.net/version.txt, C:\AutoHotkey_L Latest Version.txt
    UrlDownloadToFile, http://someorg.org/archive.zip, C:\SomeOrg's Archive.zip