doukun1450 2017-07-17 11:01
浏览 49
已采纳

无法评估Laravel链接存储文件夹

This is my route:

Route::post('/articles/image/upload','ArticleController@imageUpload');

This is my controller:

    public function imageUpload(Request $request){

        $path=$request->file('wangEditorH5File')->store('/');

        return asset('storage/'.$path);

      }

I am using rich text editor to allow a user to upload their image so I have to return a url to the text editor.

I made a symbolic link using:

php artisan storage:link

that creates a symlink from public/storage to storage/app/public.

I also changed the default drive of filesystem from local to public before linked

return [


'default' => env('FILESYSTEM_DRIVER', 'public'),



'cloud' => env('FILESYSTEM_CLOUD', 's3'),

'disks' => [

    'local' => [
        'driver' => 'local',
        'root' => storage_path('app'),
    ],

    'public' => [
        'driver' => 'local',
        'root' => storage_path('app/public'),
        'url' => env('APP_URL').'/storage',
        'visibility' => 'public',
    ],

    's3' => [
        'driver' => 's3',
        'key' => env('AWS_KEY'),
        'secret' => env('AWS_SECRET'),
        'region' => env('AWS_REGION'),
        'bucket' => env('AWS_BUCKET'),
    ],

],

];

After all is set, the text editor returns an error message that tells me I can not get the url of the image.

It means I can't access the storage folder under public .

I tried to put an image in the css folder and change the asset() function

public function imageUpload(Request $request){

    $path=$request->file('wangEditorH5File')->store('/');

    return asset('css/111.jpg');

}

It works for css and image shows up.

  • 写回答

1条回答 默认 最新

  • doucan8276 2017-07-17 12:15
    关注

    Problem solved.

    If you create symlink under windows,here is the solution

    php artisan storage:link does not work with homestead. Instead delete the folder, manually recreate them on the machine using homestead ssh and ln -s ~/projects/my-website/storage/app/public/ ~/projects/my-website/public/storage.

    From other question ->Laravel storage can't be accessed

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 树莓派与pix飞控通信
  • ¥15 自动转发微信群信息到另外一个微信群
  • ¥15 outlook无法配置成功
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题