当我将图像上传到本地主机中的存储文件夹时,它工作正常。但是,当我将 Laravel 5.7 项目移动到共享主机时,图像不会出现,我也不知道为什么。
谢谢您的帮助。
刀
@foreach ($data as $user)
@foreach(json_decode($user->name, true) as $images)
@endforeach
@endforeach
<!-- Wrapper for slides -->
<div class="carousel-inner">
@foreach ($data as $user)
@foreach(json_decode($user->name, true) as $images)
<div class="item">
<img src="{{ asset('/slider/images') }}/{{$images}}" alt="Los Angeles" style="width:100%;">
</div>
@endforeach
@endforeach
</div>
控制器
<?php
if ($request->hasfile('image')) {
foreach ($request->file('image') as $image) {
$name = $image->getClientOriginalName();
$image->move(storage_path() . '/slider/images/', $name);
$data[] = $name;
}
$query = DB::table('slider')->insert([
['title' => 'lorem', 'alt' => 'lorem', 'name' => json_encode($data)],
]);
return "good";
} else {
return "null";
}