Home >Backend Development >PHP Tutorial >PHP method to convert uploaded word files into HTML_PHP tutorial
This article describes the example of how to convert uploaded word files to html in php. Share it with everyone for your reference. The specific implementation method is as follows:
Upload page:
?
|
<🎜>"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
Receiving page:
?
|
<🎜>"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
"; $uploadfile = $uploaddir.$filename.substr($_FILES['filename']["name"],strpos($_FILES['filename']["name"],".")); //Directory name.File name.Suffix name echo $uploadfile; echo " "; $temploadfile = $_FILES['filename']['tmp_name']; echo $temploadfile; echo " "; move_uploaded_file($temploadfile, $uploadfile); //Move file $path = $_SERVER['SCRIPT_FILENAME']; $filepath = $_SERVER["PHP_SELF"]; $path = substr($path,0,strpos($path,$filepath)); echo $path; echo " "; echo $filepath; $htmlpath = $path."/shiyan4/".$uploadfile; echo " "; echo $htmlpath; word2html($htmlpath); //$query =@mysql_query( "Insert into $username(fname,file)values('$filename','$uploadfile')")or die("error"); ?> <🎜>//http://tieba.baidu.com/f?kz=13975389<🎜> <🎜>function word2html($wfilepath)<🎜> <🎜>{<🎜> <🎜>$word=new COM("Word.Application") or die("Cannot open MS Word");<🎜> <🎜>$word->visible = 1 ; $word->Documents->Open($wfilepath)or die("Cannot open this file"); $htmlpath=substr($wfilepath,0,-4); $word->ActiveDocument->SaveAs($htmlpath,8); $word->quit(0); } print( "Word to HTML converted!" ); ?> |
I hope this article will be helpful to everyone’s PHP programming design.