首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Laravel Jetstream照片最大尺寸

Laravel Jetstream照片最大尺寸
EN

Stack Overflow用户
提问于 2021-03-24 02:50:40
回答 1查看 316关注 0票数 0

虽然是PHP和Laravel的新手,但仍在与之抗争。我正在Jetstream上使用Laravel 8。现在,在前端的Edit-Section中上传新的个人资料-图片时,前端只接受小于1MB的文件。

检查我的PHP.ini,它设置为100M -所以,正常情况下它应该可以工作。你有什么想法,在哪里可能会有额外的验证或限制?

最佳皮埃尔

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-03-24 03:07:12

app\Actions\Fortify\UpdateUserProfileInformation.phpupdate()方法中,可以验证可以作为头像'photo' => ['nullable', 'image', 'max:1024']上传的图像的大小。

请参阅下面的方法:

代码语言:javascript
复制
public function update($user, array $input)
{
        
    Validator::make($input, [
        'name' => ['required', 'string', 'max:255'],
        'email' => ['required', 'email', 'max:255', Rule::unique('users')->ignore($user->id)],
        'photo' => ['nullable', 'image', 'max:1024'],
    ])->validateWithBag('updateProfileInformation');

    if (isset($input['photo'])) {
        $user->updateProfilePhoto($input['photo']);
    }

    if ($input['email'] !== $user->email &&
        $user instanceof MustVerifyEmail) {
        $this->updateVerifiedUser($user, $input);
    } else {
        $user->forceFill([
            'name' => $input['name'],
            'email' => $input['email'],
            'designation' => $input['designation'],
            'currentemployer' => $input['currentemployer'],
            'employementtype' => $input['employementtype'],
        ])->save();
    }
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66769509

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档