【发布时间】:2018-12-19 20:08:50
【问题描述】:
我想将服务器上的默认 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);
}
【问题讨论】:
-
/home/cem与/home/cemo有效吗? -
你能用
mod_write之类的代替吗? -
@KamilG。我现在编辑了它
-
@fyroc 导致 500 内部服务器错误
-
不应该吗?
<?php symlink('/home/cemo/cem/storage/app/public','/home/cemo/public_html/media');
标签: laravel-5