laravel - 移动项目目录后存储链接不起作用
问题描述
我再次尝试了 php artisan storage:link,我已经更改了公共目录,这是在将文件夹移动到另一个驱动器后发生的。
文件系统配置:
'disks' => [
'local' => [
'driver' => 'local',
'root' => storage_path('app/public'),
],
'public' => [
'driver' => 'local',
'root' => storage_path('app/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'),
],
控制器方法:
public function store(){
$data = request()->validate([
'caption' => 'required',
'image' => 'required',
]);
$imagePath=request('image')->store('uploads','public');
//interventionImage
$image =Image::make(public_path("storage/{$imagePath}" ))-
>fit(1200,1200);
$image->save();
//changes to $data arrays
auth()->user()->posts()->create([
'caption' =>$data['caption'],
'image' => $imagePath,
]);
// \App\Post::create($data);
return redirect('/profile/' .auth()->user()->id);
html图片:
<img src="/storage/{{$postId->image}}" alt="photo is not available !" c
class="w-100">
我收到以下错误
“图像源不可读错误”
解决方案
推荐阅读
- c - Is there any way to figure out that child process was killed with SIGKILL by the kernel when the parent process isn't root
- angular - 未加载源,使用 ssr 服务时永远等待 localhost
- python - 如何将字符串转换为列表?
- google-speech-api - google cloud speech to text rest api return empty response
- ios - iOS part of viewcontroller goes black when orientation changes
- python - How can command list display be categorised within a Click chained group?
- java - java中数字2^1000的位数之和
- regex - How can I solve the problem with fake/unwanted domain redirection?
- bash - 是否可以使用多个命令行参数运行 matlab 函数?
- reactjs - Typescript-Generic-Type 扩展并具有默认值