Php 如何在控制器laravel中访问blob列(图像)的值
我通过ajax jquery在laravel中进行实时搜索 我将html代码从控制器发送到视图,但无法显示blob列的值Php 如何在控制器laravel中访问blob列(图像)的值,php,laravel,Php,Laravel,我通过ajax jquery在laravel中进行实时搜索 我将html代码从控制器发送到视图,但无法显示blob列的值 function search (Request $request) { if($request->ajax()) { $output=''; $data=Club::all(); foreach($data as $record) {
function search (Request $request) {
if($request->ajax())
{ $output='';
$data=Club::all();
foreach($data as $record)
{
$output.='
<tr>
<td > '.$record->name.'</td>
<td > '.$record->country.'</td>
<td ><img src="data:image/png;charset=utf8;base64,{{base64_encode('.$record-
>logo.')}}" ></img></td> //this is uncorrect what is the correct syntax here???
</tr>
';
}
echo json_encode($output);
}
}
函数搜索(请求$Request){
如果($request->ajax())
{$output='';
$data=Club::all();
foreach($数据作为$记录)
{
$output.='
“.$record->name。”
“.$record->country。”
logo.')}}“>//这是不正确的。这里的正确语法是什么???
';
}
echo json_编码($output);
}
}
如果($request->ajax())
{
$output='';
$data=Club::all();
$path=$record->logo;
$type=pathinfo($path,pathinfo_扩展名);
$data=文件\获取\内容($path);
$base64='data:image/'.$type.';base64'.base64_encode($data);
foreach($数据作为$记录)
{
$output.='
“.$record->name。”
“.$record->country。”
//这不正确这里的正确语法是什么???
';
}
echo json_编码($output);
}
echo
json\u encode()
将接收对象或数组,而不是HTML,从API返回数据,然后在前端格式化
if($request->ajax())
{ $output='';
$data=Club::all();
return json_encode($data); \\ return rather than display
}
谢谢您的回答对我帮助很大,但不是正确的,而是帮助我制定了解决方案。@mdeveloper如果有帮助,请检查正确答案
if($request->ajax())
{ $output='';
$data=Club::all();
return json_encode($data); \\ return rather than display
}