php實(shí)現(xiàn)將上傳word文件轉(zhuǎn)為html的方法
本文實(shí)例講述了php實(shí)現(xiàn)將上傳word文件轉(zhuǎn)為html的方法。分享給大家供大家參考。具體實(shí)現(xiàn)方法如下:
上傳頁(yè)面:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>文件上傳</title> </head> <body> <form action="receivefile.php" method="post" enctype="multipart/form-data"> <input type="file" name="filename" /> <input type="submit" /> </form> </body> </html>
接收頁(yè)面:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>接收上傳文件</title> <?php $conn = @new COM("ADODB.Connection"); $connstr = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" . realpath("person.mdb"); $conn->Open($connstr); $uploaddir = 'uploads/'; if(!is_dir($uploaddir)){ mkdir($uploaddir); } $filename =$_FILES['filename']['name']; $filename =substr($_FILES['filename']["name"],0,strpos($_FILES['filename']["name"],".")); echo $filename; echo "<br>"; $uploadfile = $uploaddir.$filename.substr($_FILES['filename']["name"],strpos($_FILES['filename']["name"],".")); //目錄名.文件名.后綴名 echo $uploadfile; echo "<br>"; $temploadfile = $_FILES['filename']['tmp_name']; echo $temploadfile; echo "<br>"; move_uploaded_file($temploadfile , $uploadfile); //移動(dòng)文件 $path = $_SERVER['SCRIPT_FILENAME']; $filepath = $_SERVER["PHP_SELF"]; $path = substr($path,0,strpos($path,$filepath)); echo $path; echo "<br>"; echo $filepath; $htmlpath = $path."/shiyan4/".$uploadfile; echo "<br>"; echo $htmlpath; word2html($htmlpath); //$query =@mysql_query( "Insert into $username(fname,file)values('$filename','$uploadfile')")or die("error"); ?> <?php //http://tieba.baidu.com/f?kz=13975389 function word2html($wfilepath) { $word=new COM("Word.Application") or die("無(wú)法打開(kāi) MS Word"); $word->visible = 1 ; $word->Documents->Open($wfilepath)or die("無(wú)法打開(kāi)這個(gè)文件"); $htmlpath=substr($wfilepath,0,-4); $word->ActiveDocument->SaveAs($htmlpath,8); $word->quit(0); } print( "Word轉(zhuǎn)html完成!" ); ?> </head> <body> </body> </html>
希望本文所述對(duì)大家的php程序設(shè)計(jì)有所幫助。
相關(guān)文章
PHP文字轉(zhuǎn)圖片功能原理與實(shí)現(xiàn)方法分析
這篇文章主要介紹了PHP文字轉(zhuǎn)圖片功能原理與實(shí)現(xiàn)方法,結(jié)合具體實(shí)例形式分析了php基于gd2擴(kuò)展庫(kù)生成圖片的相關(guān)配置及使用方法,需要的朋友可以參考下2017-08-08php將會(huì)員數(shù)據(jù)導(dǎo)入到ucenter的代碼
php下把會(huì)員數(shù)據(jù)導(dǎo)入到ucenter代碼,需要的朋友可以參考下。2010-07-07php獲取網(wǎng)頁(yè)標(biāo)題和內(nèi)容函數(shù)(不包含html標(biāo)簽)
有時(shí)候我們需要獲取網(wǎng)頁(yè)的標(biāo)題與內(nèi)容,就是個(gè)采集函數(shù),這里簡(jiǎn)單分享下,方便需要的朋友2014-02-02PHP類相關(guān)知識(shí)點(diǎn)實(shí)例總結(jié)
這篇文章主要介紹了PHP類相關(guān)知識(shí)點(diǎn),結(jié)合實(shí)例形式總結(jié)分析了php類相關(guān)的最終類、最終方法、抽象類、抽象方法、接口、重載、魔術(shù)方法等相關(guān)概念與操作技巧,需要的朋友可以參考下2016-09-09PHP框架Laravel插件Pagination實(shí)現(xiàn)自定義分頁(yè)
這篇文章主要為大家詳細(xì)介紹了PHP框架Laravel5.1插件Pagination實(shí)現(xiàn)自定義分頁(yè)的相關(guān)資料,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2016-05-05詳談PHP面向?qū)ο笾谐S玫年P(guān)鍵字和魔術(shù)方法
下面小編就為大家?guī)?lái)一篇詳談PHP面向?qū)ο笾谐S玫年P(guān)鍵字和魔術(shù)方法。小編覺(jué)得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2017-02-02php下關(guān)于中英數(shù)字混排的字符串分割問(wèn)題
要用到短信平臺(tái)的緣故,短信每條又有字?jǐn)?shù)的限制,而短信平臺(tái)的服務(wù)端又不會(huì)自己分析。短信平臺(tái)的后臺(tái)會(huì)自己分割,但api卻有沒(méi)這個(gè)功能。2010-04-04