Forum

Thread tagged as: Question, Problem

PDF Downloading with path as filename

I've got a file download feature linking to PDFs. However they download with the full path to the pdf as the filename e.g..

_siteadmin_resources_pdfName.pdf

The code is as follows:

<a href="<perch:content id="download" type="file" output="path" />" download="<perch:content id="download" type="file" />" class="<perch:content id="download" type="file" output="mime" replace="application/|,text/|,vnd.openxmlformats-officedocument.wordprocessingml.document|doc,msword|doc"/>" title="Download Specification Sheet">Download full technical specification...</a>

Anu suggestions how to get the file to simply download with it's original filename instead of the path?

Tony Astley

Tony Astley 0 points

  • 3 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

From my understanding of the download attribute, you should set that to be the file name. At the moment you've set it to be the path.

Perfect, the corrected code looks like:

<a href="<perch:content id="download" type="file" output="path" />" download="<perch:content id="download" output="filename" type="file" />" class="type <perch:content id="download" type="file" output="mime" replace="application/|,text/|,vnd.openxmlformats-officedocument.wordprocessingml.document|doc,msword|doc"/>" title="Download Specification Sheet">Download full technical specification...</a>