移动项目目录后,存储链接不起作用

时间:2019-06-28 10:01:32

标签: laravel hyperlink storage

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

我遇到以下错误

  

“图像源无法读取错误”

0 个答案:

没有答案