在Cpanel上的Laravel项目中上传图像 [英] Upload Image In Laravel Project On Cpanel
本文介绍了在Cpanel上的Laravel项目中上传图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
上传图片是我的功能,但是问题是为什么图片没有上传到public_html文件夹,而图片却上传到项目的公用文件夹.
It is My function to upload the image but the question is this why the images are not uploaded to public_html folder the images are uploaded in public folder of project.
private function upload($image, $tbl)
{
$name = $image->getClientOriginalName();
$newName = date('ymdgis') . $name;
$image->move(public_path() . '/img' . $tbl, $newName);
return $newName;
}
推荐答案
在 AppServiceProvider
中,将此代码放在 register()
上:
In AppServiceProvider
put this code on register()
:
public function register()
{
$this->app->bind('path.public', function() {
return base_path('../public_html');
});
}
这篇关于在Cpanel上的Laravel项目中上传图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文