php – 将图像保存在公共文件夹中而不是存储laravel 5
发布时间:2020-12-14 19:45:56 所属栏目:大数据 来源:网络整理
导读:我想将我的头像保存在“公共”文件夹中并进行检索. 好.我可以保存它,但在“存储/应用程序”文件夹而不是“公共” 我的朋友告诉我去“config / filesystem.php”并编辑它,所以我这样做了 'disks' = [ 'public' = [ 'driver' = 'local','root' = storage_path(
我想将我的头像保存在“公共”文件夹中并进行检索.
好.我可以保存它,但在“存储/应用程序”文件夹而不是“公共” 我的朋友告诉我去“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); (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |