Laravel 空间媒体库-当前请求在名为'pic'的密钥中没有文件`

Laravel 空间媒体库-当前请求在名为'pic'的密钥中没有文件`,laravel,laravel-5,spatie,Laravel,Laravel 5,Spatie,我正在使用Spatials媒体库来处理我的图像。我正在尝试允许用户以多部分形式上传图像 我在尝试继续时遇到此错误 当前请求在名为pic 这是在请求中,就像我做这个一样 dd($validatedData) 我得到以下信息 这是我的控制器功能 public function postStep2(Request $request){ $validatedData = $request->validate([ 'pic' => 'required'

我正在使用Spatials媒体库来处理我的图像。我正在尝试允许用户以多部分形式上传图像

我在尝试继续时遇到此错误

当前请求在名为
pic

这是在请求中,就像我做这个一样

dd($validatedData)
我得到以下信息

这是我的控制器功能

  public function postStep2(Request $request){
      $validatedData = $request->validate([
        'pic' => 'required'
      ]);



      if(empty($request->session()->get('user'))){
            $user = new User();
            $user->addMediaFromRequest('pic')->toMediaCollection('profile_image');
            $request->session()->put('user', $user);
        }else{
            $user = $request->session()->get('user');
            $user->addMediaFromRequest('pic')->toMediaCollection('profile_image');
            $request->session()->put('user', $user);
        }


      return redirect('/step3');
    }
这是我的看法

<div class="user-icon--uploader-wrapper">
  <div class="previews"></div>
  <input type="file" name="pic" id="pic">
</div>

这是完整的表格

<form action="/step2" id="signupForm" method="POST" class="register-form" enctype="multipart/form-data">
      {{ csrf_field() }}

      <h4 class="step-heading btn-margin">Step 2 - Verification</h4>


      <div class="input--file youth-photo">
        <h3 class="input--file__title">Photo of Your Passport </h3>
        <div class="user-icon--uploader-wrapper">
          <div class="previews"></div>
          <input type="file" name="pic" id="pic">
        </div>
          <span class="personalphoto">Only a photo of your passport displaying  your photo and information will be permitted.</span>
      </div>


        <div class="input--submit">
          <button type="submit" class="btn-pill--filled complete-step">Go To The Next Step</button>
        <div class="youth-registration__steps-list">
          <p>
            Step 2 of 3 <span>Completed</span>
          </p>
        </div>
      </div>
    </form>

{{csrf_field()}}
步骤2-核查
你护照的照片
只允许您的护照照片显示您的照片和信息。
转到下一步

第2步(共3步)已完成


将默认媒体表迁移文件编辑为:

Schema::create('media', function (Blueprint $table) {
        $table->bigIncrements('id');
        $table->string('model_type');
        $table->uuid('model_id');
        $table->uuid('uuid')->nullable();
        $table->string('collection_name');
        $table->string('name');
        $table->string('file_name');
        $table->string('mime_type')->nullable();
        $table->string('disk');
        $table->string('conversions_disk')->nullable();
        $table->unsignedBigInteger('size');
        $table->json('manipulations');
        $table->json('custom_properties');
        $table->json('responsive_images');
        $table->unsignedInteger('order_column')->nullable();
        $table->nullableTimestamps();
    });
}

你能展示你的整个表单,包括开始标签吗?如果你将你的验证规则更改为
'pic'=>'required | file'
它仍然通过了吗?这就解决了我的问题。谢谢你的帮助