|
<?php
//header("Content-type:text/html;");
//word转html 展示
$lj=$_GET['file'];//传来的是文件位置 具体看自己的传值 upload/user/20170306/20170306xgtlne.doc
$lj=("/",'\\',$lj);//把路径改为\号 例如 upload\user\20170306\20170306xgtlne.doc
function word2html($wordname,$htmlname)
{
$word = new COM("word.application") or die("Unable to instanciate Word");
$word->Visible = 1;
$word->Documents->Open($wordname);
$word->Documents[1]->SaveAs($htmlname,8);
$word->Quit();
$word = null;
unset($word);
}
//服务器或本地的word具体位置 例如'D:\phpStudy\WWW\GongshuUnion\.upload\user\20170306\20170306xgtlne.doc'
$address='D:\phpStudy\WWW\GongshuUnion\\';
word2html($address.$lj,$address.$lj.".html");
//跳转时可以在后最加上.html
//例如 $url= http://localhost/GongshuUnion/upload/user/20170306/20170306xgtlne.doc.html
//我这里一共传了两个值 一个是 $_GET['file'] = upload/user/20170306/20170306xgtlne.doc
//另一个是$_GET['url']=http://localhost/GongshuUnion/upload/user/20170306/20170306xgtlne.doc.html
$url= $_GET['url'];
("Location:$url");
?> |
|
|