作者koizumisyou (不小的挑战)
看板PHP
标题Re: [请益] 请问下载档案
时间Fri Sep 14 17:50:15 2012
感谢C大回覆
但是我输出的CSV都是网页原始档
比如说程式码是
<html>
<head>
<title>测试</title>
</head>
<body>
<form name="form1" method="post" action="">
<input type="submit" name="button2" id="button2" value="送出">
</form>
</body>
</html>
<?php
if(isset($_POST['button2'])){
$F=date ('md');
$Wr=fopen('php://output','w+');
fputcsv($Wr,array('编号','名称','制作员','尺寸','出厂日','制作日期','制作时间'));
header("Content-type:text/x-csv");
header("Content-Disposition:attachment;filename=$F.csv");
}?>
====
输出的CSV 变成
编号,名称,制作员,尺寸,出厂日,制作日期,制作时间
<head>
<title>测试</title>
</head>
<body>
<form name="form1" method="post" action="">
<input type="submit" name="button2" id="button2" value="送出">
</form>
</body>
</html>
请问哪里出错了~谢谢
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 61.63.34.193
1F:→ bibo9901:你跟本搞错header的意思... 09/14 17:59
3F:→ chenlarry:header前面不能有任何的输出.... 09/14 23:31
4F:→ backfish:你的action要指到另一个专门产生csv档的程式啦 09/16 21:31
5F:→ koizumisyou:谢谢各位大大,已解决 09/17 01:01