使用PHP更改rtf文档并下载msword文件 您是否意识到您实际上并不是从rtf模板创建msword文件?只是假装这样做,你可能想看看这个问题,结果是我提交给PHP文件的不是表单post,而是使用AJAX和JQuery的post。当我将表单中的元素直接放

使用PHP更改rtf文档并下载msword文件 您是否意识到您实际上并不是从rtf模板创建msword文件?只是假装这样做,你可能想看看这个问题,结果是我提交给PHP文件的不是表单post,而是使用AJAX和JQuery的post。当我将表单中的元素直接放,php,rtf,Php,Rtf,使用PHP更改rtf文档并下载msword文件 您是否意识到您实际上并不是从rtf模板创建msword文件?只是假装这样做,你可能想看看这个问题,结果是我提交给PHP文件的不是表单post,而是使用AJAX和JQuery的post。当我将表单中的元素直接放入PHP文件时,没有问题。有人知道为什么吗? <?php $pname = $_POST['pname']; $countyres = $_POST['countyres']; $a1name = $_POST['

使用PHP更改rtf文档并下载msword文件
您是否意识到您实际上并不是从rtf模板创建msword文件?只是假装这样做,你可能想看看这个问题,结果是我提交给PHP文件的不是表单post,而是使用AJAX和JQuery的post。当我将表单中的元素直接放入PHP文件时,没有问题。有人知道为什么吗?
<?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();
?>