Php 当我尝试在laravel中上传图像时,我总是收到一个419错误页面过期

Php 当我尝试在laravel中上传图像时,我总是收到一个419错误页面过期,php,laravel,Php,Laravel,这是我的edit.blade.php,在这里我显示了更新用户配置文件并上传其图像的表单 <!-- form start --> <form action="{{ route('profile.update') }}" method="POST" role="form" enctype="multipart/form-data"> @csrf <div cla

这是我的edit.blade.php,在这里我显示了更新用户配置文件并上传其图像的表单

<!-- form start -->
                  <form action="{{ route('profile.update') }}" method="POST" role="form" enctype="multipart/form-data">
                  @csrf

                  <div class="card-body">
                        @if (session('status'))
                            <div class="alert alert-success" role="alert">
                                {{ session('status') }}
                            </div>
                        @endif
                        <div class="form-group row">
                            <label for="profile_image" class="col-md-4 col-form-label text-md-right">Profile Image</label>
                            <div class="col-md-6">
                                <input id="profile_image" type="file" class="form-control" name="profile_image">
                                @if (auth()->user()->image)
                                    <code>{{ auth()->user()->profile()->image }}</code>
                                @endif
                            </div>
                        </div>

                        <div class="form-group row">
                            <label for="address" class="col-md-4 col-form-label text-md-right">{{ __('Enter First Name:') }}</label> ....

这是我调用updateprofile()的Profilescontroller


请帮我检查我的代码,我用谷歌搜索我的错误,唯一的解决办法是添加我已经完成的crsf

提交表单时发生问题?是否使用资源控制器?显示您的路由文件。我添加了方法('POST')以离开页面,但我收到了新错误BadMethodCallException method App\Http\Controllers\ProfilesController::uploadOne不存在。尽管我之前添加了use-App\Traits\UploadTrait;在我的ProfilesController中,
uploadOne()
不存在,在
ProfilesController
中。是的,但我在
命名空间App\Http\Controllers中调用了它;使用light\Support\Str;使用\Http\Resquest;使用App\Traits\UploadTrait;使用App\Http\Requests
 public function updateProfile(Request $request)
    {
        // Form validation
        $request->validate([
            'profile_image'    => 'required|image|mimes:jpeg,png,jpg,gif|max:2040',
            'address'          => 'required',
            'phoneno'          => 'required',
            'sex'              => 'required',
            'martial_status'   => 'required'
        ]);

        // Get current user
        $user = User::findOrFail(auth()->user()->id);
        // Set user name
        $user->accno = $request->input('accno');

        //check if a profile image has been uploaded
        if ($request->has('profile_image')) {
            // Get image file
            $image = $request->file('profile_image');
            // Make a image name based on user name and current timestamp
            $name = Str::slug($request->input('accno')).'_'.time();
            // Define folder path
            $folder = '/uploads/images/';
            // Make a file path where image will be stored [ folder path + file name + file extension]
            $filePath = $folder.$name. '.' . $image->getClientOriginalExtension();
            // Upload image
            $this->uploadOne($image, $folder, 'public' , $name);
            // Set user profile image path in database to filePath
            $user->profile()->profile_image = $filePath;
        }
        // Persist user record to database
        $user->save();

        // Return user back and show a flash message
        return redirect()->back()->with(['status' => 'Profile updated successfully.']);
    }