<?php
$pname = $_POST['pname'];
$countyres = $_POST['countyres'];
$a1name = $_POST['a1name'];
$a2name = $_POST['a2name'];
$month = $_POST['month'];
$day = $_POST['day'];
$year = $_POST['year'];
$county = $_POST['county'];
$ha1name = $_POST['ha1name'];
$ha2name = $_POST['ha2name'];
$atty = $_POST['atty'];
$FileContent = file_get_contents('xyzs.rtf');
$FileContent = str_replace('%pname%', $pname, $FileContent);
$FileContent = str_replace('%countyres%', $countyres, $FileContent);
$FileContent = str_replace('%A1name%', $a1name, $FileContent);
$FileContent = str_replace('%A2name%', $a2name, $FileContent);
$FileContent = str_replace('%pmonth%', $month, $FileContent);
$FileContent = str_replace('%day%', $day, $FileContent);
$FileContent = str_replace('%year%', $year, $FileContent);
$FileContent = str_replace('%county%', $county, $FileContent);
$FileContent = str_replace('%HA1name%', $ha1name, $FileContent);
$FileContent = str_replace('%HA2name%', $ha2name, $FileContent);
$FileContent = str_replace('%atty%', $atty, $FileContent);
$fn = $pname.".doc";
file_put_contents($fn, $FileContent);
header('Content-Disposition: attachment; filename="'.$fn.'"');
header('Content-type: application/msword');
echo $fn;
exit();
?>
我有一个html表单,我发布了上述变量。我期待加载和rtf模板文件,进行搜索并替换文档内的变量。
有两个问题: 1.当我查看Chrome工具中的响应时,它仅为我提供了附加扩展名的文件名。
`2。我没有被提示下载该文件。
谢谢。