如何使用php保存rtf文件?

|
$rtf=<<<RTF
    {\\rtf1
    \\b [TITLE] \\b0\\par
    \\b [MESSAGE] \\b0\\par
    }
RTF;

$rtf = str_replace(\'[TITLE]\',$valueTitle,$rtf);
$rtf = str_replace(\'[MESSAGE]\',$valueMessage,$rtf);
在完成上述php中的rtf文件的编辑后,如何在特定位置使用新文件名保存该文件供人们下载?     
已邀请:
        您可以将其保存为save1ѭ,只需提供带有相应标题的下载链接即可。
// $rtf holds your complete file data
file_put_contents(\'/path/to/outfile.rtf\', $rtf);
然后,您可以直接给他们直接下载,或使用像这样的正确标题提供它,如果您需要其他处理或访问保护等功能,则很有用...
header(\"Content-type: application/rtf\");
echo file_get_contents(\"/path/to/outfile.rtf\");
exit();
    
        在我已经完成此操作的旧文件中找到了,所以这是我现在正在使用的确切工作代码。
$rtf= file_get_contents(\'result.rtf\');

$rtf = str_replace(\'[nickname]\', $nickname, $rtf);
$rtf = str_replace(\'[secretWord]\', $secretWord, $rtf);
$rtf = str_replace(\'[hoursInADay]\', $hoursInADay, $rtf);
$rtf = str_replace(\'[hobby]\', $hobby, $rtf);
$rtf = str_replace(\'[hobbyYears]\', $hobbyYears, $rtf);
$rtf = str_replace(\'[hobbyAlphabet]\', $hobbyAlphabet, $rtf);
$rtf = str_replace(\'[jokeFact]\', $jokeFact, $rtf);

header(\'Content-type: application/msword\');
header(\'Content-Disposition: attachment; filename=survey_result.rtf\');
echo $rtf;
die();
    

要回复问题请先登录注册