Skip Navigation

[Resolved] Direct link to download file/PDF

This thread is resolved. Here is a description of the problem and solution.

Problem:
How to open link of PDF file stored with custom field.

Solution:
You can use HTML anchor tag and views shortcode of custom field that returns PDF link.

Please check solution on the following reply:
https://toolset.com/forums/topic/direct-link-to-download-filepdf/#post-389968

Relevant Documentation:
=> https://toolset.com/documentation/customizing-sites-using-php/functions/
=> https://toolset.com/documentation/user-guides/using-custom-fields/
=> https://toolset.com/documentation/user-guides/displaying-wordpress-custom-fields/

This support ticket is created 8 years 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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/Kolkata (GMT+05:30)

Tagged: 

This topic contains 4 replies, has 2 voices.

Last updated by suneT 8 years ago.

Assisted by: Minesh.

Author
Posts
#388853

I am trying to: Make a list/view that consist of a custom type that contains a file/PDF. I want to be able to download the file directly from the list instead of clicking on an item -> then go to the type and then download

I visited this URL: you can see the list here hidden link (login with hugogames/123456) ....

I expected to see:

Instead, I got:

#389856

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

This can only be achieved by adding some server-side code (in PHP). There are no attributes in HTML to force download.

Here's an example on how to do it, with ready to use code: http://stackoverflow.com/a/364950

Please take care of validation of the filename if you decide to implement it, especially the line with $file = $_GET["file"] .".pdf" needs attention.

#389962

Hi 🙂

I dont need to force the download - i just need to go to the URL of the file attached to Custom File Type, when clicking the filename in the list - instead og going to the "template" for the custom file type and the download the file.

In other I need the title in the list to link to the attached file and not to the post-url...

I hope you can help 🙂

Br
/sune

#389968

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

What if you try following code:

<a href="[types field="your-field" output="raw"][/types]">CLICK HERE TO DOWNLOAD</a>
#390018

perfect - thx 🙂

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.