dongpang1898 2015-04-15 11:12
浏览 57

php中的header()没有下载文件

I am trying to read the file from php and downloading it from the ui on click of a button

<?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!!!";
}
?>

But the file is not getting downloaded. No error, the code is working. unlink() function deleted the file.

  • 写回答

1条回答 默认 最新

  • dqoeghe9452 2015-04-15 11:22
    关注

    Assuming my comment answers yes to all, then the only think i see that might be an issue.

    application/csv

    Should be:

    text/csv

    评论

报告相同问题?

悬赏问题

  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 目详情-五一模拟赛详情页
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b