Difference between revisions of "WebFile.ForceDownload"

From Xojo Documentation

m
(Notes)
 
Line 10: Line 10:
 
== Notes ==
 
== Notes ==
 
When [[True]], the browser will always download the file rather than try to display it. For example, most web browsers will try to display simple text files and many will display PDF files inline. Set '''ForceDownload''' to True to instead ensure these types of files are downloaded instead.
 
When [[True]], the browser will always download the file rather than try to display it. For example, most web browsers will try to display simple text files and many will display PDF files inline. Set '''ForceDownload''' to True to instead ensure these types of files are downloaded instead.
 +
 +
If you find that FireFox users can't download files, try using [[WebSession.GotoURL]] and pass [[True]] for the InNewWindow parameter as well as having the user disable popup blockers.
  
 
== Example ==
 
== Example ==

Latest revision as of 17:38, 2 September 2020

Property (As Boolean )
aWebFile.ForceDownload = newBooleanValue
or
BooleanValue = aWebFile.ForceDownload

New in 2010r5

Supported for all project types and targets.

Indicates whether the browser will always download the file instead of trying to display it (depending on the MIMEType). The default is False.

Notes

When True, the browser will always download the file rather than try to display it. For example, most web browsers will try to display simple text files and many will display PDF files inline. Set ForceDownload to True to instead ensure these types of files are downloaded instead.

If you find that FireFox users can't download files, try using WebSession.GotoURL and pass True for the InNewWindow parameter as well as having the user disable popup blockers.

Example

Create a new file for downloading:

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!"

ShowURL(TextFile.URL) // This causes the file to be downloaded