作者热门文章
- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我想将我的头像保存在“Public”文件夹中然后检索。
好的。我可以将它保存在“storage/app”文件夹中而不是“public”
我的 friend 告诉我去“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');
Controller
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',
'url' => env('APP_URL').'/public',
'visibility' => 'public',
]
]
你可以通过
访问它Storage::disk('public')->put('filename', $file_content);
关于php - 将图像保存在公用文件夹中而不是存储 laravel 5,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42562203/
我是一名优秀的程序员,十分优秀!