forcefully download any file php 2 comments

////save this file abc.php
/////on any ahref
///USAGE SAVE IT AS SOME abc.php----->on ahref of any link pass --------abc.php?vi=pathname

    //$tmp_path = "pdf/";
    $path_file =$_GET['vi'];
    //$tmp_file = $tmp_path.$tmp_file;

    if($path_file <> "")
        $fileName = $path_file;
        header("Content-type: application/force-download");
        header("Content-Disposition: attachment; filename=".$fileName);
        header("Pragma: no-cache");

$File = 'bpo_productlinks.csv';
header ("Content-Type: application/download");
header ("Content-Disposition: attachment; filename=$File");
header("Content-Length: " . filesize($File));
$fp = fopen($File, "r");

Other very Quick Fix…

Just add..below lines in your .htaccess file..
If you want to download and PDF file.
You just need to give full path to your anchor tag

<a href="">File Name</a>

AddType application/octet-stream .pdf

Share on Facebook

About Pragnesh Karia

Pragnesh Karia, Open Source Enthusiast, Software Professional, Software Developer, Technical Lead ,Magento, Joomla ,Joomla LMS , Moodel LMS ,PHP ,Mysql, Ajax, Javascript, Jquery, Linux, Fan of Open Sources , Annet Technologies , SEO Analyst , Mootools

2 thoughts on “forcefully download any file php