Skip Navigation

[Resolved] download file button

This support ticket is created 2 years, 11 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 1 reply, has 2 voices.

Last updated by Waqar 2 years, 11 months ago.

Assisted by: Waqar.

Author
Posts
#2319937

I'm trying to make a download file button.

I have a file field. It can be any type of file, but generally a png mp4 or pdf.

I want people to be able to just download the file when clicking a button. I added the button to the content template and attached it to the appropriate field however it just opens the file in a new window. how can I make the button download the file?

#2320261

Hi,

Thank you for contacting us and I'd be happy to assist.

To make the browser download a file when its link is clicked, the 'download' attribute can be used:
hidden link

For example, suppose you have a file type field with slug 'post-file' and its download link will look like this:


<a href="[types field='post-file' output='raw'][/types]" download>Download file</a>

I hope this helps and please let me know if you need any further assistance around this.

regards,
Waqar