Php 如何将上载图像保存在公用/存储的post文件夹中
我正试图将上传的图像保存到Php 如何将上载图像保存在公用/存储的post文件夹中,php,laravel,Php,Laravel,我正试图将上传的图像保存到public\u html/storage/post/。但现在这段代码对我不起作用,并上传到directpublic\uhtml/ $image = $request->file('image'); $slug = str_slug($request->title); if(isset($image)) { // make unipue name for image
public\u html/storage/post/
。但现在这段代码对我不起作用,并上传到directpublic\uhtml/
$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";
}
已修复
config/filesystems.php
public root中的问题
'root'=>public_path()。/../public_html/storage',
问题已在config/filesystems.php
public root中修复
'root'=>public_path()。/../public_html/storage',
你做过php artisan存储:链接吗?是的,我做过存储:链接你做过php artisan存储:链接吗?是的,我做过存储:链接