编写一个php程序
读取一个文本文件内容,将其输出为Word文档,并能够显示“文件下载”对话框,以便下载该Word文档...
读取一个文本文件内容,将其输出为Word文档,并能够显示“文件下载”对话框,以便下载该Word文档
展开
2个回答
展开全部
写的比较简单,大概思路就是这样,你自己再改改就ok了
a.php
<?php
rename("C:/my/path/file.txt","C:/my/path/file.doc");
?>
<a href="b.php">下载</a>
b.php
<?php
$file = "C:/my/path/file.doc";
header("Content-Disposition: attachment; filename=file.doc");
header('Content-Transfer-Encoding: binary');
header("Content-Description: File Transfer");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: public");
header("Content-Type: $ctype");
header("Content-Length:".filesize($file));
flush();
readfile($file);
?>
a.php
<?php
rename("C:/my/path/file.txt","C:/my/path/file.doc");
?>
<a href="b.php">下载</a>
b.php
<?php
$file = "C:/my/path/file.doc";
header("Content-Disposition: attachment; filename=file.doc");
header('Content-Transfer-Encoding: binary');
header("Content-Description: File Transfer");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: public");
header("Content-Type: $ctype");
header("Content-Length:".filesize($file));
flush();
readfile($file);
?>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询