0

(download.php)

......(other HTML code)......
$filepath = '/storage/uploaded_files/'.$thisSysName;
header("Content-Type: application/force-download"); 
header('Content-Description: File Transfer');
header('Content-Transfer-Encoding: binary');
header('Connection: Keep-Alive');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Disposition: attachment; filename="'.basename($filepath).'"'); 
readfile($filepath);
......(other HTML code)......

The dialog did show on the IE, but the content of that file is the content of HTML (download.php).

Weird.

K.W.
  • 141
  • 1
  • 15

1 Answers1

3

......(other HTML code)...... (Line 1)

You cant send headers to a browser after you've already sent contents to it. In other words, headers are the first thing a browser should receive.

For more information refer to this answer

Community
  • 1
  • 1
Krimson
  • 7,386
  • 11
  • 60
  • 97
  • Thanks! Now I only made it into one PHP file with GET and without any other HTML unnecessary code. Then I downloaded the empty HTML file, it seems like the same result above. – K.W. Feb 18 '14 at 07:41
  • @K.W. Is it possible post the first few lines of your php file? because if you are just getting the html file, im pretty sure that something is leaking before the headers. Also is your site live? If it is I can examine whats leaking in – Krimson Feb 18 '14 at 07:44