Php 图像未在Laravel DOMPDF中显示(仅在服务器中)
我正在使用dompdf在laravel中做一个在线证书生成部分。在更换服务器之前,它一直工作正常。现在没有显示图像(证书模板的背景图像和学生的个人资料图片)。它显示错误“未找到图像或类型未知”。它在localhost中运行良好。错误仅在服务器中发生 这是我的控制器:Php 图像未在Laravel DOMPDF中显示(仅在服务器中),php,html,css,laravel,dompdf,Php,Html,Css,Laravel,Dompdf,我正在使用dompdf在laravel中做一个在线证书生成部分。在更换服务器之前,它一直工作正常。现在没有显示图像(证书模板的背景图像和学生的个人资料图片)。它显示错误“未找到图像或类型未知”。它在localhost中运行良好。错误仅在服务器中发生 这是我的控制器: public function certPdfGenerate() { ini_set('memory_limit', '-1'); $apply_id= input::get('id'); $get_ce
public function certPdfGenerate()
{
ini_set('memory_limit', '-1');
$apply_id= input::get('id');
$get_certificate_data = DB::Connection('mysql1')->table('tbl_apply_certificate')->where('apply_id',$apply_id)->first();
$get_certificate_id1 = DB::Connection('mysql1')->table('tbl_apply_certificate')->select('apply_certificate_id')->where('apply_id',$apply_id)->get()->toArray();
foreach ($get_certificate_id1 as $key)
{
$get_certificate_id = $key->apply_certificate_id;
}
$filename = $get_certificate_id.'.pdf';
DB::Connection('mysql1')->table('tbl_apply_certificate')
->where('apply_id', $apply_id)
->update(['apply_pdf' => $filename]);
$data1 = [$get_certificate_data];
$pdf=PDF::loadView('students::htmlcertificate', array('data' =>$data1), [], ['format' => 'A4-L']);
$pdf->setPaper('A4', 'landscape');
return $pdf->stream($filename);
}
这是我的查看页面
<!DOCTYPE html>
<html>
<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="csrf-token" content="{{ csrf_token() }}">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Certificate View</title>
<style type="text/css">
@page
{
size: 21.87cm 30.69cm landscape;
margin-top:0;
margin-bottom:0;
margin-left:0;
margin-right:0;
padding: 0;
}
body
{
position: relative;
}
#certbackground
{
background-image: url('https://example.com/backend/public/cer_template/certtemplate.png');
background-repeat: no-repeat;
background-position: center;
background-size: contain;
z-index: -1;
height: 100%;
width: 100%;
top: 0;
left: 0;
position: absolute;
}
</style>
</head>
<body>
<div id="certbackground">
@foreach ($data as $value)
<h3 style="margin-top: 860px;margin-left: 1370px;font-weight: 600;font-size:60px;color: #333;">{{$value->apply_name}}</h3>
<img style="height: 600px!important;margin-top: -18px;margin-left: 2880px;" src="{{ URL::asset('public/certif_pro_image/'.$value->apply_photo) }}" />
<h3 style="top:-160px!important;margin-top:-500px!important;margin-left: 1370px;font-weight: 600;font-size:60px;color: #333;">{{$value->apply_course}}</h3>
<h3 style="position:absolute;top:1310px!important;margin-left: 1930px;font-weight: 600;font-size:60px;color: #333;">{{date('d-m-Y', strtotime($value->apply_start_date))}}</h3>
<h3 style="position:absolute;top:1250px!important;margin-left: 2370px;font-weight: 600;font-size:60px;color: #333;">{{date('d-m-Y', strtotime($value->apply_end_date))}}</h3>
<h3 style="position:absolute;top:1410px!important;margin-left: 1580px;font-weight: 600;font-size:60px;color: #333;">{{$value->apply_grade}}</h3>
<h3 style="position:absolute;top:1410px!important;margin-left: 2290px;font-weight: 600;font-size:60px;color: #333;">{{$value->apply_certificate_id}}</h3>
<h3 style="position:absolute;top:1575px!important;margin-left: 1575px;font-weight: 600;font-size:60px;color: #333;">{{$value->apply_centre}}</h3>
@endforeach
</div>
</body>
</html>
证书视图
@页面
{
尺寸:21.87厘米30.69厘米景观;
边际上限:0;
页边距底部:0;
左边距:0;
右边距:0;
填充:0;
}
身体
{
位置:相对位置;
}
#证书背景
{
背景图像:url('https://example.com/backend/public/cer_template/certtemplate.png');
背景重复:无重复;
背景位置:中心;
背景尺寸:包含;
z指数:-1;
身高:100%;
宽度:100%;
排名:0;
左:0;
位置:绝对位置;
}
@foreach(数据为$value)
{{$value->apply_name}
应用(照片)}}”/>
{{$value->apply_course}
{date('d-m-Y',strottime($value->apply_start_date))}
{date('d-m-Y',strottime($value->apply_end_date))}
{{$value->apply_grade}
{{$value->apply_certificate_id}
{{$value->apply_center}
@endforeach
仔细检查证书-如果在浏览器中加载图像并检查证书,是否存在任何ssl错误?此类错误通常会阻止加载资源的pdf呈现。已检查..它在localhost中运行良好。只有在更改了server@SreyaSRVJames要求您在服务器上测试图像,而不是在localhost.tested.image正在浏览器中加载。但它不会显示在pdf中。未显示的图像是CSS中引用的图像?您是否启用了对远程资源的支持?Dompdf是否具有对临时目录的读/写访问权限?仔细检查证书-如果您在浏览器中加载图像并检查,是否存在ssl错误证书?此类错误通常会阻止加载资源的pdf呈现。已检查。。它在本地主机中运行良好。只有在更改server@SreyaSRVJames要求您在服务器上测试图像,而不是在localhost.tested上。图像正在浏览器中加载。但它不会显示在pdf中。未显示的图像是oCSS中引用的ne?是否启用了对远程资源的支持?DOMPF是否具有对临时目录的读/写访问权限?