最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
php 生成word文档并下载代码
时间:2022-06-24 18:34:56 编辑:袖梨 来源:一聚教程网
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来发送给浏览器。
*/
相关文章
- 燕云十六声金妙音石归鸿速刷攻略 07-01
- 崩坏星穹铁道3.2末日幻影打法技巧指南 07-01
- 怪物猎人荒野特产采集路线分享 07-01
- ps给人物制作添加影子效果教程 07-01
- 金铲铲之战s14超频源计划纳亚菲利阵容搭配推荐 07-01
- Pi2Day之后暴跌,用户怒斥“割韭菜”? 07-01