最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
php 生成word文档并下载代码
时间:2010-06-04 编辑:简简单单 来源:一聚教程网
php教程 生成word文档并下载代码
include("include/conn_mysql教程.php");
$id=$_GET["id"];
$sql="select * from down where id=$id ";
$result=mysql_query($sql);
$row=mysql_fetch_row($result);
$file2=$row["upload"];
function downFile($sFilePath)
{
if(file_exists($sFilePath)){
$aFilePath=explode("/",str_replace("\","/",$sFilePath),$sFilePath);
$sFileName=$aFilePath[count($aFilePath)-1];
$nFileSize=filesize ($sFilePath);
header ("Content-Disposition: attachment; filename=" .basename($sFileName) );
header ("Content-Length: " . $nFileSize);
header ("Content-type: application/octet-stream");
mb_convert_encoding(readfile($sFilePath),"utf-8","GB2312");
}
else
{
echo("文件不存在!");
}
}
downFile($file2);
/*
这个生成word生成文档程序是从mysql数据库教程读取数据保存文件再用header来发送给浏览器。
*/
-
上一个: 简单的php日历类控件代码实例
-
下一个: php 科学计数的参数转换成整数程序
相关文章
- PHP图形生成库JpGraph生成图形的例子 04-05
- PHP生成唯一订单号的6种方法 08-29
- PHP5.5的迭代生成器的例子 08-10
- php中使用GD库生成图形例子 04-22
- PHP网址缩短代码(生成短网址) 12-06
- php生成饼图效果的实现代码 11-23