[Solved] php download button without submiting back to page [closed]


Use $_GET use a hyperlink instead of a submit button.

<?php
if(isset($_GET['download']) && $_GET['download']){
    header('Content-Description: File Transfer');
    header('Content-Type: application/octet-stream');
    header('Content-Type: application/octetstream');
    header('Content-Disposition: attachment; filename="'.$file_real_name.'"');
    header('Content-Transfer-Encoding: binary');
    header('Expires: 0');
    header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
    header('Pragma: public');
    header('Content-Length: ' . (int)(filesize($file_path)));
    ob_clean();
    flush();
    readfile($file_path);
}
?>
<a href="https://stackoverflow.com/questions/19016977/?download=true">Download</a>

1

solved php download button without submiting back to page [closed]