脚本宝典收集整理的这篇文章主要介绍了php – 在浏览器上显示保存在gridfs中的pdf文件的预览,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
这是服务代码
public function getIpFileByFileid() { $request = $this->request; $dm = $this->container->get('doctrine_mongodb')->getManager('patient'); $id = $request->get('fileId'); //get doc $docIpMapping = $dm->getReposITory('PatientDocumentsBundle:IPDocuments')->findOneBy([ 'id' => $id ]); $base64 = (base64_encode($docIpMapping->getFile()->getBytes())); $response['data'] = $base64; $response['msg'] = 'success'; return $response; }
这是前端代码
Ajax(path,data).success(function (result) { $("#pdfDiv").htML('<iframe style="width:100%;height:500px;" src="data:application/pdf;base64,' + result.data + '"></iframe>'); });
以上是脚本宝典为你收集整理的php – 在浏览器上显示保存在gridfs中的pdf文件的预览全部内容,希望文章能够帮你解决php – 在浏览器上显示保存在gridfs中的pdf文件的预览所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。