簡體   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