微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

php – 将图像保存在公共文件夹中而不是存储laravel 5

我想将我的头像保存在“公共”文件夹中并进行检索.

好.我可以保存它,但在“存储/应用程序”文件夹而不是“公共”

我的朋友告诉我去“config / filesystem.PHP”并编辑它,所以我这样做了

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

仍然没有变化.

这是我的简单代码

路线:

Route::get('pic',function (){
return view('pic.pic');
});
Route::post('saved','test2Controller@save');

调节器

public function save(Request $request)
{
        $file = $request->file('image');
        //save format
        $format = $request->image->extension();
        //save full adress of image
        $patch = $request->image->store('images');

        $name = $file->getClientOriginalName();

        //save on table
        DB::table('pictbl')->insert([
            'orginal_name'=>$name,'format'=>$base,'patch'=>$patch
        ]);

        return response()
               ->view('pic.pic',compact("patch"));
}

视图:

{!! Form::open(['url'=>'saved','method'=>'post','files'=>true]) !!}
                {!! Form::file('image') !!}
                {!! Form::submit('save') !!}
            {!! Form::close() !!}

                <img src="storage/app/{{$patch}}">

如何在公共文件夹而不是存储中保存我的图像(以及将来的文件)?

在config / filesystems.PHP中,你可以这样做……
在公共场合更改根元素
'disks' => [
   'public' => [
       'driver' => 'local','root'   => public_path() . '/uploads',]
]

你可以通过它访问它

Storage::disk('public')->put('filename',$file_content);

原文地址:https://www.jb51.cc/laravel/135060.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。