6 Ways to Force Download Instead of Opening File in Browser

When clicking on a file URL, users are often redirected to a new tab to preview the file by default. This allows them to check the file content and decide whether they should download it.

There are still times that you intend to force users to download the file instead of opening it in a new browser. It’s when the file is too large or offered as a digital product.

If you’re finding a way to push users to download files once clicking, you’re in the right place. This article will show you 5 easy methods to obtain that.

Before guiding you through the process, let us explain 2 main reasons why you should force files to be downloaded automatically.

When to Force File Downloading

There are 2 main reasons for getting a file downloaded automatically after a click.

Firstly, it might be because you offer a really large item. Rather than attempting to finish a 100-page PDF once, readers often break them down and digest each small part at a time.

To avoid going online every time viewing that file, they can download it to their device and open it anywhere at any time.

Another case is selling digital products such as PDF ebooks or course videos. Forcing downloads makes sure customers receive what they pay for. From the administrator’s point of view, this method frees them from manually sending customers downloadable files.

How to Force File Downloading Manually

#1 Force File Downloading Using Zip Files

Zip files refer to a combination of one or more files that are compressed into a single file for easier transportation and compression.

All you need to do is group your desired files into a folder on your device. After that, you right-click that folder and choose the option Compress “folder-name”. You can send this zip file to users via emails or social platforms. Recipients simply click on the file and download it in seconds.

However, what they’ll get is also a zip file. They have to double click and expand it to access all media files.

 pda-compress-folder-zip-file

#2 Force File Downloading Using Code

If you’re tech-savvy and prefer solving problems with code, this solution is for you! You should use the following code and add it to the .htaccess file of your server.

<FilesMatch "\.(?i:pdf)$">
ForceType application/octet-stream
Header set Content-Disposition attachment
</FilesMatch>

The word “pdf” in the code above can be changed into any file types you plan to force downloads. In case you want users to click and download multiple different files, just replace the (?i:pdf) with (mov|mp3|jpg|pdf).

#3 Force File Downloading Using <a href> Tag

Using the <a href> tag enables your media files to be auto-downloaded to the user’s desktop as well. Follow these 5 straightforward steps:

  1. Open your WordPress page or post
  2. Click on the Add Media button above the toolbar
    pda-add-media
  3. Pick your desired files and add them to the content
  4. Open the page’s Text editor screen and add this tag to the file area. The “myfile.pdf” is your file name.
    <a href="myfile.pdf" download>Click to Download</a>
  5. Update your post and now you’re done.

How to Force File Downloading Using Tools

#4 Force File Downloading Using Amazon S3

Amazon S3 works as powerful storage to save your website or app data. You now can also use it to ensure a forced download of files stored there.

To achieve that, you must set the right headers on your Amazon S3 files when uploading them there.

Follow this rule:

Content-Disposition: attachment; filename=FILENAME.EXT
Content-Type: application/octet-stream

#5 Ensure Items are Forced to Download Using Dropbox

Dropbox refers to a file hosting service offering cloud storage, file synchronization, personal cloud, and client software.

Still, many of its users don’t notice its tiny feature of having files auto-downloaded when users click on it.

To use this tool for forcing file downloading, you can add the parameter “dl=1” to the end of your download link. Here is an example of a correct file URL with the parameter: https://www.yourdomain.com/s/a1b2c3d4ef5gh6/filename.pdf?dl=1.

#6 Force File Downloading Using PDA Gold Plugin

Primarily coming as a media file protection plugin, PDA Gold permits you to force file downloading on WordPress sites in a minute.

The plugin helps protect your file’s URLs and replace them with private download links. Instead of sending users the original links, you can give them these download links to auto-download your files.

PDA Gold proves a more efficient solution for numerous reasons. You’re able to restrict download times on your files based on time or clicks. After a certain day or a number of clicks, users can no longer download that file.

On top of that, these download links can be generated automatically or customized on your own.

You can refer to this article on how to create private download links for your WordPress images, documents, or even videos.

Out of the box, PDA Gold integrates seamlessly with Amazon S3 and Dropbox to auto-protect your files uploading there.

What’s Your Method to Force File Downloading?

Forcing users to download files after a click makes sure they have large files downloaded on their computer. Customers can also receive their digital product right after purchase.

There are 2 different paths you can take to force file downloading. Manual ways require you to add tags or code to your site. Using tools like Amazon S3, Dropbox, and PDA Gold help significantly simplify the process.

What method will you use and why? Share with us your opinion in the comment box below.

Leave a Reply

Your email address will not be published. Required fields are marked *