我有问题,显示的内容或docx
文件在php(laravel 5)
。
我没有找到任何解决方案来显示内容。我用phpword
lib阅读,我读了phpword的文档,但没有找到解决方案。
这里是我的代码:
+上传HTML:show doc,docx文件内容php
<form method="post" action="doc/upload" enctype="multipart/form-data">
{{csrf_field()}}
<input type="file" name="file" accept=".doc, .docx"/>
<button class="btn btn-primary" style="margin-top: 5px"><span class="glyphicon glyphicon-import" aria-hidden="true"></span> Upload</button>
</form>
+过程:
public function upload(Request $request){
$file = $request->file('file');
$phpWord = \PhpOffice\PhpWord\IOFactory::load($file);
//i use this line below for showing but it can not show exactly
$phpWord->save('php://output');
}
您缺少标题信息,即浏览器没有获得足够的有关如何处理输出的信息。检查http://stackoverflow.com/questions/33872714/php-word-send-generated-file-to-browser-as-output-without-saving-it-on-disc的类似问题。 – ejuhjav