如何将上载路径更改为public_html而不是public laravel
我使用laravel背包,并尝试上传图片。在当地工作。但在服务器上的图像上传到公共,并没有显示在网站上,我尝试改变磁盘和文件系统,但没有改变 //模型如何将上载路径更改为public_html而不是public laravel,laravel,backpack-for-laravel,Laravel,Backpack For Laravel,我使用laravel背包,并尝试上传图片。在当地工作。但在服务器上的图像上传到公共,并没有显示在网站上,我尝试改变磁盘和文件系统,但没有改变 //模型 public function setPosterAttribute($value) { $attribute_name = "poster"; $disk = "public"; $destination_path = "uploads/products/posters";
public function setPosterAttribute($value)
{
$attribute_name = "poster";
$disk = "public";
$destination_path = "uploads/products/posters";
// if the image was erased
if ($value==null) {
// delete the image from disk
\Storage::disk($disk)->delete($this->{$attribute_name});
// set null in the database column
$this->attributes[$attribute_name] = null;
}
// if a base64 was sent, store it in the db
if (starts_with($value, 'data:image'))
{
// 0. Make the image
$image = \Image::make($value);
// 1. Generate a filename.
$filename = md5($value.time()).'.jpg';
// 2. Store the image on disk.
\Storage::disk($disk)->put($destination_path.'/'.$filename, $image->stream());
// 3. Save the path to the database
$this->attributes[$attribute_name] = $destination_path.'/'.$filename;
}
}
//文件系统
'public' => [
'driver' => 'local',
'root' => public_path(),
'visibility' => 'public',
],
在公共数组中,根被设置为
public\u path()
,这是指向public
文件夹的路径。如果要更改,应将配置更改为以下内容:
'public' => [
'driver' => 'local',
'root' => base_path('public_html'),
'visibility' => 'public',
],
在公共数组中,根被设置为
public\u path()
,这是指向public
文件夹的路径。如果要更改,应将配置更改为以下内容:
'public' => [
'driver' => 'local',
'root' => base_path('public_html'),
'visibility' => 'public',
],