WebFile.MIMEType

From Xojo Documentation

Revision as of 16:08, 11 August 2017 by PLefebvre (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Property (As String )
aWebFile.MIMEType = newStringValue
or
StringValue = aWebFile.MIMEType

New in 2010r5

Supported for all project types and targets.

This is the MIME type of the content. Browsers rely on this to determine what to do with the content. Setting WebFile.ForceDownload to True will override the MIMEType. Defaults to "application/octet-stream".

Example

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

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