php - 刀片文件上未显示图像
问题描述
为什么即使在执行符号链接之后,我的图像也没有显示在实时托管的刀片文件中,ps:-它在 localhost 上运行良好
后控制器:
public function createpost(Request $request)
{
Post::create(
[
'user_id'=>$request->user_id,
'post_title'=>$request->post_title,
'post_body'=>$request->post_body,
'post_image'=>$request->file('post_image')->store('public'),
'status'=>1
]);
echo "Recorded Successfully";
echo "<a href='/post'>Click here</a> to go back";
}
文件系统.php
'disks' => [
'local' => [
'driver' => 'local',
'root' => storage_path('app'),
],
'public' => [
'driver' => 'local',
'root' => storage_path('public'),
'url' => env('APP_URL').'/storage',
'visibility' => 'public',
],
's3' => [
'driver' => 's3',
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'region' => env('AWS_DEFAULT_REGION'),
'bucket' => env('AWS_BUCKET'),
'url' => env('AWS_URL'),
],
],
Blade.php 文件
{{url('storage/'.$post->post_image) }}
解决方案
您可以使用asset()
助手
{{ asset('storage/' . $post->post_image) }}
或者Storage
门面
{{ Storage::url($post->post_image) }}
推荐阅读
- julia - Julia 中的 Convolution3d 实现
- ios - 如何在 UITabBarController 中使用 UINavigationController
- video - 禁止使用 Admob!奖励视频?
- ruby-on-rails - 如何使 ActiveStorage 在我的语言环境中工作?
- google-app-engine - 有没有办法从谷歌云实例中导出你的 app.yaml 文件
- printing - 如何在主要参数之外打印?(可以办到)
- mysql - 如何在mysql中按名称DISTINCT查询计数
- python - 如何在 Python 中截取具有特定像素范围的屏幕截图?
- java - 不丢失现有数据的对象映射
- java - 如何通过windows命令提示符安装java?