-4

重複の可能性:
PHP - ファイルをユーザーに送信

サーバー上の CSV ファイルにユーザーデータを正常に出力するスクリプトを作成しました。

私の質問: ユーザーが開くことができるように CSV ファイルをポップアップ表示する方法はありますか? 現状では、ファイルを開く唯一の方法はサーバーから直接です。

4

1 に答える 1

2
<?php
    $csv_file = '/path/to/yourfile.csv'; // path to the csv file you're generating on the server

    header('Content-type: text/csv');
    header('Content-Disposition: attachment; filename="'.basename($csv_file));

    readfile($csv_file);
?>
于 2012-05-02T14:40:40.450 に答える