teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

1

追記あり

2016/07/08 05:58

投稿

SONIK
SONIK

スコア14

title CHANGED
File without changes
body CHANGED
@@ -22,4 +22,22 @@
22
22
  header('Content-Length: '.filesize($filepath));
23
23
 
24
24
  readfile($filepath);
25
+ ```
26
+
27
+ [追記]
28
+
29
+ 以下の方法でやると、HTML文が全文出た後に出力予定のcsvファイルの中身が
30
+ 出力されました。
31
+
32
+ ```php
33
+ // ファイルのパス
34
+ $filepath = 'test.csv';
35
+ // リネーム後のファイル名
36
+ $filename = 'テスト.csv';
37
+
38
+ header('Content-Description: File Transfer');
39
+ header("Content-Disposition: attachment; filename=$filename");
40
+ header('Content-Type: application/force-download;');
41
+
42
+ readfile($filepath);
25
43
  ```