繁体   English   中英

php中的header()无法下载文件

[英]header () in php not downloading the file

我正在尝试从php中读取文件,并单击按钮从ui下载它

<?php
$file = 'download.csv'; //path to the file on disk


if (file_exists($file)) {

    header('Content-Type: application/csv');
    header('Content-Disposition: attachment; filename=contact-list.csv');
    header('Pragma: no-cache');
    readfile($file);
    //unlink($file);

    exit;
}

else {

    print "file not found!!!";
}
?>

但是该文件未下载。 没有错误,代码正在运行。 unlink()函数删除了该文件。

假设我的评论对所有人都回答是,那么我认为这可能是一个问题。

应用程序/ CSV

应该:

文/ CSV

暂无
暂无

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

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