From Xojo Documentation

You are currently browsing the old Xojo documentation site. Please visit the new Xojo documentation site!

WebFile.Download() As Boolean

Supported for all project types and targets.

Asks the browser to download the file. If this method returns true, it means that the request was sent to the browser, not that it was actually downloaded.


This example creates a text file to make available for download. You can put it on the Action event handler for a WebButton so that the file is downloaded when the user clicks the button:

TextFile = New WebFile // TextFile is a property of the web page
TextFile.MimeType = "text/plain"
TextFile.ForceDownload = True // If False, the browser may try to display the file instead of download it
TextFile.FileName = "TextFile.txt"

TextFile.Data = "Hello, world!"

If TextFile.Download Then // This causes the file to be downloaded
// Download requested
End If