Download dialog not works - php 'headers'

edited June 2017 in CMS Modifications


I have probelm with download a file throught 'header' after redirect my site HTPP to HTTPS.

Plugin Donwload 'plugins/download/download.php' case 'dl'
I tested this code for opening download dialog and still not work :-(

$file_name = "robots.txt";

// Quick check to verify that the file exists
if (!file_exists($file_name)) die("File not found");

// Force the download
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.basename($file_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: ' . filesize($file_name));

Any idea please?


Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!