我试图在index.blade
上显示上传的图像,但它没有显示,尽管<img>
标签中的文件路径正确,而且我在控制台上判断了一下,它也得到了正确的路径.
图像存储控制器:
if($request->hasFile('profilepic')){
$file = $request->file('profilepic');
$profilepic=$file->getClientOriginalName();
$file->storeAs('public/profile', $profilepic);
$detail['profilepic'] = $profilepic;
}
if($request->hasFile('signature')){
$file1 = $request->file('signature');
$signature=$file1->getClientOriginalName();
$file1->storeAs('public/sign', $signature);
$detail['signature'] = $signature;
}
$detail->save();
return response()->json([
'status'=> 'success',
'data' => $detail
]);
Img路径的索引.Blade
<td><img src="../storage/app/public/profile/{{ $detail->profilepic }}" width="100px"></td>
<td><img src="storage/app/public/sign/{{ $detail->signature }}" width="100px"></td>
AJAX jQuery:
$(document).on('submit','.create_form',function(event)
{
event.preventDefault();
const fd = new FormData(this);
$.ajax({
url: "{{ route('details.store') }}",
data: fd,
type: "POST",
dataType: "json",
contentType: false,
processData: false,
success: function(response)
{
$(".div3").load("{{ route('details.index') }}");
},
error: function(error)
{
console.log("Errors :",error);
}
});
});
我还试着把.env
档中的APP URL
档放到<img src>
档中,但不起作用.