我的 Laravel 项目中有一个图片上传表单。我想将上传的图像保存到public/images/位置。但图像上传到public/app/images位置。这app是从哪里来的!!配置/文件系统.php'disks' => [ 'local' => [ 'driver' => 'local', 'root' => public_path(''),],'public' => [ 'driver' => 'local', 'root' => public_path(''), 'visibility' => 'public',],'s3' => [ 'driver' => 's3', 'key' => 'your-key', 'secret' => 'your-secret', 'region' => 'your-region', 'bucket' => 'your-bucket', ],],控制器if($this->request->hasFile('photo')) { $image_url = $this->request->photo->store('/images/campaign/large'); $image = substr($image_url, strrpos($image_url, '/') + 1);}我在本地项目中应用了相同的代码。图片上传到了正确的位置。但是这个问题发生在我的 cPanel 服务器项目中。我已经在实时服务器中清除了现金。错误在哪里?
3 回答
潇湘沐
TA贡献1816条经验 获得超6个赞
我认为这个控制器代码可以帮助你。
if($this->request->hasFile('photo'))
{
$image_url = $this->request->photo->store(public_path('images'));
$image = substr($image_url, strrpos($image_url, '/') + 1);
}
- 3 回答
- 0 关注
- 191 浏览
添加回答
举报
0/150
提交
取消