Browsers try to download html file instead of opening
Likely an incorrect mime type in your .htaccess file. I suggest going into it and looking for any unwanted lines similar to the below and removing them.
AddHandler application/ etc.
and also ensure your type is set as follows:
AddType text/html .html
In order to open .htaccess in cPanel:
Click File Manager and make sure to tick Show Hidden Files (dotfiles) before clicking Go. Then the .htaccess should show up the location where wp (wp-admin, wp-content, wp-includes) is installed.
How to force a Download File prompt instead of displaying it in-browser with HTML?
This is something that you cannot absolutely control with HTML itself.
If the user is having a browser with PDF reading capabilities (or a plugin) and the corresponding settings to open PDF files in-browser, the PDF will open like that.
The PDF opens in a new tab simple because of your target="_blank"
, which has nothing to do with a download prompt.
If you are using HTML5 you can use the download attribute:
<a href="sample.pdf" download="sample.pdf">Download</a>
If you have a back-end service which you can control or you feel like fiddling with your Web Server, you can always look for setting the right Content-Disposition
. See this SO question for some nice discussion on Content-Disposition.
Opening files in browser instead of downloading
add target="_blank" to get a new window. adding .pdf may help. If you have control over the host web server adjusting the headers for the files in question will also help it open inline. I can tell you what headers to set if you are able too
Related Topics
Extension Mysqli Is Missing, Phpmyadmin Doesn't Work
Passing an Array to a Query Using a Where Clause
How to Get Last Insert Id in Sqlite
How to Store Values from Foreach Loop into an Array
Convert Image to Base 64 String With Laravel
Redirect That Same Page from Where Id Is Coming
Mysql Combine Two Columns into One in Query
Keep Values Selected After Form Submission
How to Get a Youtube Video Thumbnail from the Youtube API
Getting a File to Download Instead of Opening the Browser
How to Find Out If CSV File Fields Are Tab Delimited or Comma Delimited
How to Send Data Using Redirect With Laravel
How to Pass an Array Within a Query String
Laravel - Form Input - Multiple Select for a One to Many Relationship
How to Change Default Url from Localhost:8000 to Other Ip in Laravel When We Run "Php Artisan Serve"
Auto Update Cart on Quantity Change in Woocommerce Cart Page