在我的应用程序中,用户可以根据租金项目创建收据.
header("Content-type: application/vnd.ms-word");
header("Content-disposition: attachment;Filename=Rent_Receipt_". $_SESSION['custid'] .".doc");
include ("templates/template_receipt.PHP");
现在,用户会将其存储在本地计算机上,但是如何使服务器将同一文档存储在服务器文件夹中,因此用户不必手动上传它?
提前致谢.
编辑
包括:template_receipt.PHP包含要创建的Word文档的HTML代码:
<?PHP echo "
<html xmlns:v='urn:schemas-microsoft-com:vml'
xmlns:o='urn:schemas-microsoft-com:office:office'
xmlns:w='urn:schemas-microsoft-com:office:word'
xmlns:m='http://schemas.microsoft.com/office/2004/12/omml'
xmlns='http://www.w3.org/TR/REC-html40'>
<head>
<Meta http-equiv=Content-Type content='text/html; charset=windows-1252'>
<Meta name=ProgId content=Word.Document>
<Meta name=Generator content='Microsoft Word 14'>
<Meta name=Originator content='Microsoft Word 14'>
<link rel=File-List href='Template%20Verhuurbon_files/filelist.xml'>
<link rel=Edit-Time-Data href='Template%20Verhuurbon_files/editdata.mso'>
<link rel=dataStoreItem href='Template%20Verhuurbon_files/item0001.xml'
target='Template%20Verhuurbon_files/props002.xml'>
<link rel=themeData href='Template%20Verhuurbon_files/themedata.thmx'>
<link rel=colorSchemeMapping
href='Template%20Verhuurbon_files/colorschememapping.xml'>
解决方法:
ob_ *函数会有所帮助.
例如:
<?PHP
// geting file content
ob_start();
include ("templates/template_receipt.PHP");
$content = ob_get_contents();
ob_end_clean();
//store in local file
file_put_contents('/file/name.txt',$content);
// file output:
header("Content-type: application/vnd.ms-word");
header("Content-disposition: attachment;Filename=Rent_Receipt_". $_SESSION['custid'] .".doc");
echo $content;
?>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。