Force file to download wordpress






















October 25, Force file download by adding a small code snippet to the. Problem Your visitors click links to text files or image files in the Media Library, and the file is rendered directly on the browser. Solution Follow this procedure to solve the problem described above. Learn more. Asked 4 years, 8 months ago. Active 6 months ago. Viewed 11k times. Improve this question. Community Bot 1 1 1 silver badge. Add a comment. Active Oldest Votes. Improve this answer.

This will work only in some browser. 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. If the desired directory does not contain an. 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.

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.

Firstly, it might be because you offer a really large item. Rather than attempting to finish a 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.



0コメント

  • 1000 / 1000