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 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题