请我将服务器上的默认laravel配置从storage / app / public更改为public / media。在localhost中,它与storage:link一起使用,但是在服务器上,即使添加了符号链接也无法正常工作。下面是我的符号链接代码。
<?php symlink('/home/cemo/cem/storage/app/public','/home/cemo/public_html');
如果我从store函数返回public_path(),我也会得到/ home / cemo / cem / public
this is the structure of my cpanel
以下是我使用图片干预的商店功能
public function store(Request $request)
{
return public_path();
$this->validate($request,[
'title'=>'required|min:6',
'body'=>'required'
]);
if($request->hasFile('image')){
$img = $request->file('image');
$imgName = time().'-'.uniqid() . '.' . $img->getClientOriginalExtension();
}
else{
$imgName = 'default.jpg';
}
$posts = new post;
$posts->title = $request->title;
$posts->body = $request->body;
$posts->posted_by = $request->posted_by;
$posts->status = $request->status;
$posts->position = $request->position;
$posts->image = $imgName;
$posts->source = $request->source;
$posts->save();
$posts->tags()->sync($request->tags);
if(!empty($img)){
Image::make($img)->resize(1500,550)->save(public_path('/media/images/blog/'. $imgName));
}
$notification = array(
'message' => 'Successfully created',
'alert-type' => 'success'
);
return redirect(route('post.index'))->with($notification);
}
答案 0 :(得分:0)
在config / filesystems.php
将数组更改为:
'root' => 'public/media',