Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
TXP file_download tags and the HTML download attribute
Does TXP enforce a Content-Disposition
header on txp:file_download
? And if so, does it specify a filename? That would override the value specified in the download
attribute1. Something like:
content-disposition:attachement; filename="filename.ext"
I am trying to use the download
attribute to set the file name on some downloads and override the default, but when using any of the TXP tags, this fails: the filename as registered on the server and in the TXP DB is used. From my shortcode, simplified
<txp:file_download id='<txp:yield name="id" />'>
<a href="<txp:file_download_link />" download="<txp:yield name="filename">download the file</a>
</txp:file_download>
The generated HTML code:
<a href="/file_download/322/test.txt" download="test download document.txt">Download Text</a>
The user should then find the “test download document.txt” file in her/his downloads folder (and the browser download manager), but “test.txt” is there.
I’ve tried many permutations of the code above, but as soon as I use one of the <txp:file_download_** />
tags, things go wrong.
1 references on MDN: developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition and developer.mozilla.org/en-US/docs/Web/HTML/Element/a
Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern
Offline
Offline
Re: TXP file_download tags and the HTML download attribute
Ok, thanks for confirming. The issue I have is one of versioning as TXP does not change the filename.ext when you replace the existing file with a new one. And changing the file name is one of the tricks to beat some agressive caching (less a problem nowadays, but I remember having serious issues with IE 10 and older). For the user it is also nice to have some versioning indication in the filename, especially for archiving purposes.
At the moment I use the adi_file_tab
plugin for that purpose, I was investigating if it was possible to go plugin-free for that.
Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern
Offline
Re: TXP file_download tags and the HTML download attribute
phiw13 wrote #327800:
At the moment I use the
adi_file_tab
plugin for that purpose, I was investigating if it was possible to go plugin-free for that.
One day. Bringing the coolest bits of adi_file_tab into core is on the list.
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Online
Re: TXP file_download tags and the HTML download attribute
Bloke wrote #327848:
One day. Bringing the coolest bits of adi_file_tab into core is on the list.
Now that would be nice!
Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern
Offline