download a file from a hyperlink

This forum is for all Flare issues related to the HTML5, WebHelp, WebHelp Plus, and Adobe Air Targets
Post Reply
jknasinski
Propeller Head
Posts: 36
Joined: Tue Jul 10, 2012 9:31 am
Location: Milwaukee Wisconsin

download a file from a hyperlink

Post by jknasinski »

I'm working on an HTML5 output project and I've got .xsd files that my team wants users to be able to download. So I include the .xsd file in my project and created a hyperlink to the file. When clicked it opens in a new browser window or tab, or if a user right-clicks they can select Save As... That works fine.
My team though, wants a user just to be able to click the link to start a download. I'm pretty sure that can be done, I just don't know how... Ideas?
Thanks.
Daniel Ferguson
Propeller Head
Posts: 77
Joined: Wed Jul 10, 2013 12:34 pm
Location: Salt Lake City
Contact:

Re: download a file from a hyperlink

Post by Daniel Ferguson »

Have you tried the download attribute? This has worked for me in the past.

https://www.w3schools.com/tags/att_a_download.asp

I don't think there is an option in the Flare interface for this, so you'd need to do it in your HTML code. It would look something like this:

Code: Select all

<a href="MyXSD.xsd" download="MyXSD.xsd">Download XSD file</a>
Daniel Ferguson
Certified Flare Trainer & Consultant
smartoutput.com
phillipkent
Jr. Propeller Head
Posts: 4
Joined: Fri Feb 02, 2018 9:32 am

Re: download a file from a hyperlink

Post by phillipkent »

I tried this with a Flare (version 2018) HTML5 target and did not get a download action to happen in the browser. I also found that the Flare editor sees a 'download' attribute without a value as an error, although it is valid HTML:

Code: Select all

<a href="../Resources/Download/test.txt" download>test.txt</a>
I guess to do this reliably requires some JavaScript, as shown here http://html5-demos.appspot.com/static/a.download.html, which involves generating a 'blob URL' (https://stackoverflow.com/questions/308 ... it-is-used).
NorthEast
Master Propellus Maximus
Posts: 6359
Joined: Mon Mar 05, 2007 8:33 am

Re: download a file from a hyperlink

Post by NorthEast »

phillipkent wrote:I also found that the Flare editor sees a 'download' attribute without a value as an error, although it is valid HTML:
That's because the Flare editor is using XHTML, not HTML. Attributes in XHTML can't be minimised, so they must have a value, even if it's blank like attribute=""
https://www.w3schools.com/htmL/html_xhtml.asp
Dafra08
Propeller Head
Posts: 45
Joined: Fri Aug 16, 2019 1:02 am

Re: download a file from a hyperlink

Post by Dafra08 »

Did anyone get this to work? I am trying to do the same thing.

- Adding JPG and SQL files as external resources (the files are located in \Resources\Downloads).
- Inserting a hyperlink to an individual JPG/SQL file in a topic.
- Adding the download attribute to the link.

Result: the linked file opens directly in the browser as either images or plain text instead of being downloaded.

I have tried the following values for download. All with the same result.

The logotype has to be added to the image library to make it selectable in this dropdown. <a href="Resources/Downloads/logo.jpg" download>Click here to download the logotype</a>.
The logotype has to be added to the image library to make it selectable in this dropdown. <a href="Resources/Downloads/logo.jpg" download="">Click here to download the logotype</a>.
The logotype has to be added to the image library to make it selectable in this dropdown. <a href="Resources/Downloads/logo.jpg" download="logo">Click here to download the logotype</a>.
The logotype has to be added to the image library to make it selectable in this dropdown. <a href="Resources/Downloads/logo.jpg" download="logo.jpg">Click here to download the logotype</a>.
The logotype has to be added to the image library to make it selectable in this dropdown. <a href="Resources/Downloads/logo.jpg" download="true">Click here to download the logotype</a>. (Just for the sake of it.)

Is there something wrong with the path? The files open, so there shouldn't be, but I am starting to wonder ... The question remains: How do you force a download?
Doc DJ
Jr. Propeller Head
Posts: 3
Joined: Wed Sep 16, 2020 10:57 am

Re: download a file from a hyperlink

Post by Doc DJ »

Dafra08 wrote: Is there something wrong with the path? The files open, so there shouldn't be, but I am starting to wonder ... The question remains: How do you force a download?

Not sure if you found a way to do this in Flare yet, but I believe when I looked at this in the past I discovered that the browser chooses how to handle the file - as in it's set on the client side. User's should be able to right-click to select to download instead of open the file if open is the default behavior. I personally, couldn't get the download attribute to work at all in Flare.
Madcap Guru
Sr. Propeller Head
Posts: 238
Joined: Tue Mar 17, 2009 10:41 pm

Re: download a file from a hyperlink

Post by Madcap Guru »

Nomthe download attrib will not work in Flate at all. It’s been a known issue.

Fill out a enchame t request and maybe it can be addressed in a future version
Rick Ferrell
____________________________

Former Flare and Robohelp Support
Image
lc4466
Propeller Head
Posts: 26
Joined: Tue Jun 18, 2019 10:20 am

Re: download a file from a hyperlink

Post by lc4466 »

I got this to work on my project by searching dev boards and finding out about an .htaccess file.

So I created one in my published repository that just contains:

Code: Select all

AddType application/octet-stream .txt 
AddType application/octet-stream .pdf
You should be able to add additional lines for any kind of file type you want to auto download. Then adding the download="" attribute should actually work for those files. Hope this helps because it was driving me crazy as well and this has 100% solved it for my use case!
Post Reply