Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php OctoberCMS前端文件上载不添加文件,但添加数据库条目_Php_Laravel_Octobercms - Fatal编程技术网

Php OctoberCMS前端文件上载不添加文件,但添加数据库条目

Php OctoberCMS前端文件上载不添加文件,但添加数据库条目,php,laravel,octobercms,Php,Laravel,Octobercms,我已经编辑了Rainlab用户插件,允许用户在前端上传一个文件,并附加到他们的用户配置文件中。在后端工作,但在前端不工作 内部User.php模型 public $attachOne = [ 'avatar' => 'System\Models\File', 'id_document' => 'System\Models\File' ]; /** * @var array The attributes that are mass assignable.

我已经编辑了Rainlab用户插件,允许用户在前端上传一个文件,并附加到他们的用户配置文件中。在后端工作,但在前端不工作

内部User.php模型

    public $attachOne = [
    'avatar' => 'System\Models\File',
    'id_document' => 'System\Models\File' 
];

/**
 * @var array The attributes that are mass assignable.
 */
protected $fillable = [
    'name',
    'surname',
    'login',
    'username',
    'email',
    'password',
    'password_confirmation',
    'created_ip_address',
    'last_ip_address',
    'id_document'
];
内部Account.php组件

public function onSubmit()
    {
        if (!$user = $this->user()) {
            return;
        }

        $data = post();

        if ($this->updateRequiresPassword()) {
            if (!$user->checkHashValue('password', $data['password_current'])) {
                throw new ValidationException(['password_current' => Lang::get('rainlab.user::lang.account.invalid_current_pass')]);
            }
        }

        if (Input::hasFile('avatar')) {
            $user->avatar = Input::file('avatar');

        }

        if (Input::hasFile('id_document')) {
            $user->id_document = Input::file('id_document');
        }

        $user->fill($data);
        $user->save();

        /*
         * Password has changed, reauthenticate the user
         */
        if (array_key_exists('password', $data) && strlen($data['password'])) {
            Auth::login($user->reload(), true);
        }

        Flash::success(post('flash', Lang::get(/*Settings successfully saved!*/'rainlab.user::lang.account.success_saved')));

        /*
         * Redirect
         */
        if ($redirect = $this->makeRedirection()) {
            return $redirect;
        }

        $this->prepareVars();
    }
内部update.htm组件

<form data-request="onSubmit" data-request-files data-request-flash>

  <input type="hidden" name="_handler" value="onSubmit">

  {{ form_token() }}
  {{ form_sessionKey() }}

  <div class="form-group">
      <label for="accountName">Full Name</label>
      <input name="name" type="text" class="form-control" id="accountName" value="{{ user.name }}">
  </div>

  <div class="form-group">
      <label for="accountEmail">Email</label>
      <input name="email" type="email" class="form-control" id="accountEmail" value="{{ user.email }}">
  </div>

  <div class="form-group">
      <label for="accountEmail">ID Document</label>
      <input type="file" name="id_document">
  </div>
  <div class="form-group">
      <label for="accountEmail">Avatar</label>
      <input type="file" name="avatar">
  </div>


  <button type="submit" class="btn btn-default">Save</button>

</form>

{{form_token()}}
{{form_sessionKey()}}
全名
电子邮件
身份证件
阿凡达
拯救
当我提交表单时,在system_files表中生成结果


如何确保它添加了上传文件所需的所有详细信息。即使存储也不能反映上传时的文件。

我觉得这是错误的,
Inside Account.php组件
hmm,对我来说似乎一切正常。你能移动
$user->fill($data)在文件分配之前,可能会导致问题。。。也许be@bhucho我试图更改文档,但没有成功。@HardikSatasiya在分配任务之前也尝试过将其向上移动,但也没有成功:(将尝试其他方法,看看是否出现任何问题。does
Input::hasFile()
对于两次上载的文件都返回true,您可以执行
dd(Input::hasFile());