Without putting steps in place to force a file to download, some browsers will only display the item rather than download it.
While simply showing the downloadable item such as an image and allowing the customer to download it at their pleasure is fine for some websites, other times it makes sense for the item to be directly downloaded to the visitors computer.
In this tutorial we will outline how you can always force a file to download rather than showing it in the visitors browser. If you are offering a large item, even if this is a pdf it is recommended to force this download. Your visitor may want to read this later on so having it saved to their downloads file can allow them to do this. If your customer has paid money to purchase the download, then forcing the download can ensure that they receive what they have paid for.
While viewing the download within the browser can often work for images, your user may forget to save it prior to exiting. This means that they no longer have a copy of what they purchased. If you wish for all your downloadable content to be automatically saved on your visitors computer complete one of the following options depending on your developer knowledge and website needs :. Encapsulating your downloadable items in a zip file will ensure they are forced to download.
This is a simple technique that forces the download as browsers are unable to read a zip file. This will change the behavior of the file so it is downloaded instead of displayed in the browser. You can change the file type from PDF to whatever by editing the pdf to match whichever extension is desired.
Multiple file types may be specified like so:. Here we have added three extensions, pdf , txt , and doc. So when this code is added to the root. This will match only files named magazine. To match only files contained in a specific directory, simply move the code to the.
There you can select post types , file name formats, and other general settings. Under the button positioning section, you can select the button alignment and placement. You can use the default button that comes with the plugin, or you can upload your own button image. You can add custom text, choose fonts, add custom CSS , etc.
This allows you to add watermark on your PDF files to protect them from unauthorized distribution. This plugin offers a comprehensive set of options. The default options would work for most websites, but you can review them and adjust them as needed. You can now visit any single post on your website, and you will see a PDF download icon.
Clicking on it will start the PDF download. You may also want to see our comparison of the 5 best WordPress membership plugins. If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials.
You can also find us on Twitter and Facebook. Disclosure: Our content is reader-supported. This means if you click on some of our links, then we may earn a commission. See how WPBeginner is funded , why it matters, and how you can support us. Trusted by over 1. Get FREE access to our toolkit — a collection of WordPress related products and resources that every professional should have! Community Bot 1 1 1 silver badge. Add a comment.
Active Oldest Votes. This will work only in some browser. Safari is not one of them! I needed this in my Wordpress site and it worked perfectly! Thank you! Thanks a lot jord8on. I am feeling good to heard that solution help you. Now it auto download so people open it with adobe or else.
0コメント