首页 > 解决方案 > 移动项目目录后存储链接不起作用

问题描述

我再次尝试了 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">

我收到以下错误

“图像源不可读错误”

标签: laravelhyperlinkstorage

解决方案


推荐阅读