Tuesday, October 9, 2018

How to download static docx file using php[Solved]

hey Guys, After lot of R&D I found the solution to download docx file using PHP.
Below is the example code.
function downloadDocx(){
$file = 'bikash_university.docx'
if (file_exists($file)) {
    header('Content-Description: File Transfer');
    header('Content-Type: application/octet-stream');
    header('Content-Disposition: attachment; filename='.basename($file));
    header('Expires: 0');
    header('Cache-Control: must-revalidate');
    header('Pragma: public');
    header('Content-Length: ' . filesize($file));
    ob_clean();
    flush();
    readfile($file);
    exit;
}
echo "<h1>Content error</h1><p>The file does not exist!</p>";
}

4 comments:

  1. Great post!! This can be one particular of the most useful blogs We’ve ever arrive across on this subject. Basically Wonderful. I am also a specialist in this topic so I can understand your hard work.
    HRMS Software In India
    Human Resource Management Software
    HRMS Software Chennai
    HR Software In Chennai
    HR Management Software In India
    HRMS Chennai

    ReplyDelete
  2. Pada abad ke 19, capsa susun akhirnya tersebar sampai ke Eropa tepatnya di Italia. Kartu remi yang pertama kali muncul di Eropa lebih dikenal dengan istilah Kartu Tarot (tarochi) atau tablet nasib mengingat bentuknya yang seperti tablet yang digunakan untuk meramal nasib seseorang.
    asikqq
    dewaqq
    sumoqq
    interqq
    pionpoker
    bandar ceme terbaik
    hobiqq
    paito warna
    bocoran sgp
    data hk

    ReplyDelete
  3. Thanks For Your Information. We Sphinax Info Systems are one of the leading ERP and SAP software development company in chennai India. We have more than 7+ years of strong experience in ERP Applications Development And SAP based services & support like SAP B1, SAP Hana, SAP R3 etc.. For More Info.. http://sphinaxinfosystems.com/

    ReplyDelete