php 生成word文档并下载代码
程序员文章站
2024-02-09 11:57:52
...
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("文件不存在!");
}
}
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 生成word文档并下载代码
-
PHP教程实例:用PHP脚本生成word文档的程序
-
php在程序中将网页生成word文档并提供下载的代码
-
php 备份数据库代码(生成word,excel,json,xml,sql)_php技巧
-
PHP生成迅雷、快车、旋风等软件的下载链接代码实例_PHP教程
-
在PHP中读取和写入WORD文档的代码
-
Zend Framework生成验证码并实现验证码验证功能(附demo源码下载)_PHP
-
jquery+php+ajax显示上传进度的多图片上传并生成缩略图代码_php技巧
-
sql文件 PHP备份数据库生成SQL文件并下载的函数代码
-
php将数据库中所有内容生成静态html文档的代码_php技巧