简体   繁体   English

使用php下载文件包含空值

[英]File download using php include null values

I have default csv template. 我有默认的csv模板。 I need to show this template when user click on a specific button. 当用户单击特定按钮时,我需要显示此模板。

The code is here 代码在这里

    $filePath = $_SERVER['DOCUMENT_ROOT']."/content/formatted_blank.csv";
    $csvfile  = file_get_contents($filePath);
    $filename = "formatted_blank.csv";
    echo $csvfile;
    header("Content-type: application/csv");
    header("Content-Disposition: attachment; filename=\"".$filename."\"");
    die();

The code is working fine. 该代码工作正常。 But the output file is not matching my default template. 但是输出文件与我的默认模板不匹配。 In default template i wrote header in 1 row But download file showing in 7th row. 在默认模板中,我在1行中写了标题,但在第7行中显示了下载文件。 There is white space rows coming. 会有空白行。

if any one know about this please help me. 如果有人知道这一点,请帮助我。

You can not use header functions after echo . echo后不能使用header函数。 Make the oposite 使相反

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM