问题描述:

(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.

网友答案:

......(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

相关阅读:
Top