I’m looking to do something pretty straightforward. I just want to add a pdf to Webflow to automatically download when the button is clicked. Can someone tell me how to do this really quickly?
You’ll have to host the file from a public-accessible server like dropbox or similar. Then snag the destination url and use an external link in Webflow. It’s an annoying workaround. You can vote to add this as a feature but it’ll probably never happen
I did something a couple of years ago inside Webflow. I can’t remember exactly what I did. I used a button to trigger a modal, and the modal had a form, submitting the form triggered the download.
@Citrus 's answer is the logical one for Webflow, but the links Webflow generates do not include the download attribute and even if they did, browsers exercise their own decision-making here. Most would just display the PDF on-screen.
@Port_of_Folio has the only answer I know will currently work for Webflow if you want to force a download by the browser. I use Google Drive for this, here are the details;
With the Google Drive approach, you only need the link, no special attributes- so I wonder if you could actually use the form redirect Url for this. They should only be redirected after a successful form submit.
Then the message just reads “thank you, your download will begin shortly.”
I’ve found using the form redirect as a mechanism to download files as not very reliable in the past.
Unless things have changed, it’s probably not going to work as expected.
There are some issues with Webflow forms when you don’t want to have any form inputs (just use the form button). They are workaround-able, but still exist. Of course, you could just add your own form through an embed or add it to the form action.
Beyond that, where you host your files is also dependent upon your success.
To force a download on a users computer you have to have the correct HTTP headers in your response.
…and typically, you don’t control that.
IIRC with Google Drive they do silly things like always set your header to text/html as your content type no matter what type of file it is.