【发布时间】:2018-11-01 02:10:33
【问题描述】:
我在我的 laravel 项目中安装了 phpword 包。现在,当我尝试使用此代码读取docx 文件时
public function upload(Request $request){
$file = $request->file('file');
$phpWord = \PhpOffice\PhpWord\IOFactory::load($file);
foreach($phpWord->getSections() as $section) {
foreach($section->getElements() as $element) {
if(method_exists($element,'getText')) {
echo $element->getText() . "<br>";
}
}
}
}
我遇到了一个错误
找不到类“ZipArchive”
/vendor/phpoffice/common/src/Common/XMLReader.php 第 54 行
【问题讨论】:
-
请像
php artisan config:cache和composer dump-autoload一样运行缓存清除和转储自动加载命令 -
@AddWebSolutionPvtLtd 我真是个傻瓜。你拯救了我的一天。
标签: php laravel phpword phpoffice