php 生成word文档并下载代码
2013-09-05 19:25
579 查看
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来发送给浏览器。
*/
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在程序中将网页生成word文档并提供下载的代码
- php生成txt.word.xls直接下载代码
- php生成word文档的实例代码
- php在程序中把网页生成word文档并提供下载
- php在程序中把网页生成word文档并提供下载
- 用 PHP 代码生成 Flash 文档
- 在PHP中读取和写入WORD文档的代码
- PHP生成迅雷、快车、旋风等软件的下载链接代码实例
- PHPWord生成多篇word文档的时候目录文件冗余bug解决方案
- java代码操作POI生成Word文档
- Java根据word模板生成word文档之后台解析和实现及部分代码(三)A
- aspose.words生成word文档(.dox、.docx等)时,生成目录后,目录中的页码和实际页码不对应,代码中更新域都没用
- php 生成word文档
- 利用PHPWord生成文档的应用例子
- 【原】php生成2003 word文档并以页面视图打开
- PHP生成word文档
- Java根据word模板生成word文档之后台解析和实现及部分代码(三)B
- java生成word文档到服务器,并下载