File Downloads
Last updated
Was this helpful?
Last updated
Was this helpful?
With success message.
Download file link
Changing the name of the saved file
Nice idea from Yeshai Lang
This can be done with some custom code. Embed the following script after the "Download File" button element: <script>
document.getElementById('downloadButton').addEventListener('click', function() {
var fileNameWithPrefix = this.getAttribute('data-file');
var fileName = fileNameWithPrefix.substring(fileNameWithPrefix.indexOf('_') + 1);
// Decode the filename to replace '%20' with actual spaces
fileName = decodeURIComponent(fileName);
// Create a temporary link element
var link = document.createElement('a');
link.href = 'path_to_download/' + fileName; // Replace 'path_to_download/' with your actual download path
link.setAttribute('download', fileName); // Set the download attribute to specify filename
link.style.display = 'none';
document.body.appendChild(link);
// Trigger the download
link.click();
// Cleanup: remove the temporary link element
document.body.removeChild(link);
});
</script> And create a custom element set as a button: <button id="downloadButton" data-file="{{wf {"path":"file-to-download","type":"FileRef"\} }}" class="button">Download File</button> replacing {{wf {"path":"file-to-download","type":"FileRef"\} }} with the relevant field from your cms