我正在尝试将上传的图像保存到public_html/storage/post/
中。但现在这段代码对我不起作用,并上传到direct public_html/
$image = $request->file('image');
$slug = str_slug($request->title);
if(isset($image))
{
// make unipue name for image
$currentDate = Carbon::now()->toDateString();
$imageName = $slug.'-'.$currentDate.'-'.uniqid().'.'.$image->getClientOriginalExtension();
if(!Storage::disk('public')->exists('post'))
{
Storage::disk('public')->makeDirectory('post');
}
$postImage = Image::make($image)->save($imageName);
Storage::disk('public')->put('post/'.$imageName,$postImage);
} else {
$imageName = "default.png";
}
答案 0 :(得分:0)
问题已在config/filesystems.php
公共根目录中修复为
'root' => public_path().'/../public_html/storage',