フォーラムへの返信

1件の返信を表示中 - 1 - 1件目 (全1件中)
  • フォーラム: 使い方全般
    返信が含まれるトピック: MySQLのデータをCSVにしてダウンロードしたい

    みなさんそのような回答ではだめです。

    CSVをダウンロードする際、header()が送信されるまえにプログラムを実行
    する必要があります。WordPressではその為の関数が用意されております。

    add_action( ‘init’, ‘GetUserInfoData’ );

    function GetUserInfoData(){
    if($_GET[‘page’] == ‘data_net_menu_e’){
    ここにCSVダウンロードのプログラムを記載
    header(“Content-Disposition: attachment; filename=$file_name”);
    header(“Content-Length:$file_length”);
    header(“Content-Type: application/octet-stream”);
    readfile($file);
    }
    }

1件の返信を表示中 - 1 - 1件目 (全1件中)