php - Wordpress downloadable file in costume template page with headers -


i'm trying create download links file download forced , costume page have assigned download page, problem downloads empty file, , issue not in pdf format tried images has 0 bytes files , path correct ive checked , suspect has wordpress native headers conflicting , code seems correct used in other non-wordpress sites , here code:

<?php /* template name: download-main-ebook */ ?> <?php                $file = get_stylesheet_directory_uri(). "/homepage/ebook.pdf";              header('pragma: public');   // required             header('expires: 0');       // no cache             header('cache-control: must-revalidate, post-check=0, pre-check=0');              header('cache-control: private',false);             header('content-type: '.'html');             header('content-disposition: attachment; filename=ebook.pdf');             header('content-transfer-encoding: binary');             header('content-length: '.filesize($file));   // provide file size             header('connection: close');             readfile($file);      // push out              exit();      ?> 

please !


Comments

Popular posts from this blog

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -