download link on my web page

I need to put a link on my web site that when users click will download a document to their computer.
I would like to have the document as a resource to my application … its just a small csv file.
How do I make the document something that is distributed with the application?
How do I format the link to point to that document and cause that document to be downloaded when the user clicks it?

Hi Brian,
You use a WebFile :slight_smile:
RL WebFile

Also check out the Downloading example included in Web/Downloading.

To “distribute” it with the application, assign the contents of the file to a constant, then assign it to a WebFile at runtime using WebFile.Data.

So putting a link on the page is probably not what I need, perhaps a simple button is all that is necessary to invoke the download?

Sure. Just use WebFile.URL to invoke the download.
Make sure you set ForceDownload = True on your WebFile :slight_smile:

[quote=22556:@Brian O’Brien]I need to put a link on my web site that when users click will download a document to their computer.
How do I format the link to point to that document and cause that document to be downloaded when the user clicks it?[/quote]

Hi.
Something I whipped up for you guys :

<!DOCTYPE html>
<html lang=”en”> 
<meta charset=”utf-8?>
<head>
<title>DL example</title>
</head>
<body bgcolor=#FFFF00> <!--Yellow -->

<h1>Download and display link examples.</h1>
<!-- This example was created by Mason Mack. It was intentionally kept minimal to not add confusion. See you on the xojo forum! -->
<!-- To use this example simply copy and paste it into your website then 
create testfiles with the correct file names and extensions (testfile.txt, testfile.pdf and testfile.zip) and
have them located in the same directory as this html page. Then
run this page in your browser and click the links.
For testing purposes the files don't actually have to be the real file types so you can create a testfile.txt then duplicate it and 
just change the filetype extensions and the browser treat them like the real thing.
-->

<!-- This demonstration will show you how to create a website download link that your users can click to download your xojo applications or other files. -->
<!-- Remember to always compress your binary xojo application builds for downloading. -->

<!-- For testing purposes create a text file of the targeted filenames (see below and notice the different file extentions) located in the same directory 
as this webpage. -->
<!-- notice the browser treats the different file extensions differently -->


<p>This example was created by Mason Mack and it shows how to create a download link that allows users to download your Xojo applications or other files. 
It also shows how to make a link which displays a document in the visitors web browser.
I hope you enjoy it and see you on the Xojo forum!</p>

<br> <br>
<p> To use this example simply copy and paste it into your website then create testfiles with the correct file names and extensions 
(testfile.txt, testfile.pdf and testfile.zip) and have them located in the same directory as this html page. Then
visit this page in your browser and click the links.
Notice how the different file extensions are treated differently by the web browser.
Some file extenstions are normally defaulted to display while others are defaulted to download.</p>
<p>Document types are often defaulted to display in the browser but users can optionally right click to download them without viewing them.
If you have a document (or other file) that you want users to be able to download by clicking the link then compress it to a .zip file or other compression type 
because compressed file extensions are defaulted to download.</p>

<a href="testfile.txt" 	download>Displays testfile.txt in the browser or right clicking allows the user to download it.</a>
<br>
<a href="testfile.pdf" 	download>Displays testfile.pdf in the browser or right clicking allows the user to download it.</a>
<br>
<a href="testfile.zip" 	download><b>Downloads</b> the testfile.zip file to the user's predefined browser download folder.</a>


<br> <br>

<a href="https://xojo.com/">Check out these <b>cool</b> Xojo products!</a>
<p>
The <i>GREAT</i> Xojo forum community is found <a href="https://forum.xojo.com/3350-download-link-on-my-web-page">here</a>
</p>
</body>

</html>