错误:从服务器收到重复的标头

时间:2015-12-30 09:14:44

标签: php

在chrome,opera,safari中发生了Dublicate错误,只能在firefox上运行。 这是标题:

| Header
    | Forcing a download using readfile()
    |----------------
    */

    header('Content-Description: File Transfer');
    header('Content-Type: ' . $file_mime_type);
    header('Content-Disposition: attachment; filename=' . $file);
    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: ' . $file_size);
    ob_clean();
    flush();
    readfile($file_path);
    exit;

我试图使用双引号和作品,但添加了文件名 - 例如 - ' filename.pdf'

header("Content-Disposition: attachment; filename= . '$file'");

1 个答案:

答案 0 :(得分:0)

解决您需要的问题

// Change this 
header('Content-Disposition: attachment; filename=' . $file);

// To this 
header('Content-Disposition: attachment; filename="'.$file.'"');