diff --git a/application/controllers/info_amp.php b/application/controllers/info_amp.php index 6bfd4ecf..8f06663e 100644 --- a/application/controllers/info_amp.php +++ b/application/controllers/info_amp.php @@ -382,25 +382,25 @@ class Info_amp extends CI_Controller } $md5_name = $md5_file.$ext; $path = realpath('../cht-system/views/information/word_source').'/'.basename($md5_name); - $html = realpath(APPPATH.'/libraries/composer/vendor/'); + $html = 'to use mammoth'; if (move_uploaded_file($file['tmp_name'], $path)) { - $this->load->library('wordphp'); - $rt = new WordPHP(); - $rt->img_dir = realpath('../cht-system/views/information/word_img'); - $rt->img_prex = $md5_file; - $html = $rt->readDocument($path); - $html = str_ireplace($rt->img_dir, '//202.103.68.62:9096/information-view/information/word_img', $html); - /*//phpWord转HTML - require_once($html.'/autoload.php'); - $phpWord = \PhpOffice\PhpWord\IOFactory::load($path); - $xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, "HTML"); - $xmlWriter->save($path.'.html'); - */ - echo(json_encode(array( - 'status' => 'success', - 'path' => $path, - 'html' => $html - ))); + $docx_dir = realpath('../cht-system/views/information/word_source'); + $img_dir = $docx_dir.'/'.$md5_file; + @mkdir($img_dir, 0700); + $html_parh = $img_dir.'/'.$md5_name; + //运行docx转化插件 + $command = 'C:\Users\cht77\AppData\Local\Yarn\bin\mammoth '.$path.' --output-dir='.$img_dir; + exec($command, $rs); + $html = file_get_contents(str_ireplace('.docx', '.html', $html_parh)); + //图片前缀 + //$html = str_ireplace($img_dir, '//202.103.68.62:9096/information-view/information/word_source', $html); + if ($html) { + echo(json_encode(array( + 'status' => 'success', + 'path' => $path, + 'html' => $html + ))); + } } else { echo(json_encode(array( 'status' => 'error',