图像文件未移动到路径

image file is not moving to the path

我正在尝试实现更新配置文件功能,这是保存数据的表单 form

这是应该将图像保存到路径 controller

的控制器

用户class.

中照片与用户有关系
class User extends Authenticatable
{
    use Notifiable;

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'firstName', 'lastName','userName' ,'email', 'password','photo_id',
    ];

    /**
     * The attributes that should be hidden for arrays.
     *
     * @var array
     */
    protected $hidden = [
        'password', 'remember_token',
    ];

    public function photo(){
        return $this->belongsTo('App\Photo');
    }

这是请求文件。

public function rules()
    {
        return [
            'firstName'=> 'required',
            'lastName' => 'required',
            'userName' => 'required',
            'photo_id' => 'required',
            'email' => 'required',
        ];
    }

根据你的问题,我假设你的问题只是图像没有被移动到正确的路径。在你的控制器中尝试像这样改变它

$file->move(yourdirectory .'/images/', $name);

注意.和 / 在目录的开头。如果你想要 public 路径使用 public_path() 函数。

当你想使用你应该添加的文件时:

'files' => true

您的表单选项:

{!! Form::model($user, [..., 'files' => true]) !!}

(代替 ...,您应该输入其他选项 - 抱歉,我不会从图像中写文字)