Zahra Aleem Zahra Aleem - 1 year ago 82
PHP Question

Download pdf from href link issue

I am working on a wordpress. I make a meta field for upload pdf file,pdf file upload sucessfully. Now i call meta value in href link for download the pdf file.But the problem is that it can open the file but not download.For this i search a code that is

header("Content-Disposition: attachment; filename=$event_flyer");

$event_flyer is used for accessing meta value.

but its not working for specific href its just working for whole page on refresh.

Answer Source

If you want your pdf file to be downloadable by anyone who could browse your website just by clicking on links, then you can use the download attribute (for tags) which allows you to specify the linked resource :

Doc here :

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download