【问题标题】:Laravel Jetstream Photo Max SizeLaravel Jetstream 照片最大尺寸
【发布时间】:2021-03-24 03:24:56
【问题描述】:

PHP 和 Laravel 的新手,但正在努力克服它。我正在使用带有 Jetstream 的 Laravel 8。现在,在前端的编辑部分中上传新的个人资料图片时,前端只接受

检查了我的 PHP.ini,它设置为 100M - 所以,通常它应该可以工作。任何想法,哪里可能有额外的验证或限制?

最好的 皮埃尔

【问题讨论】:

    标签: laravel jetstream


    【解决方案1】:

    在app\Actions\Fortify\UpdateUserProfileInformation.php 的update() 方法中,验证了您可以作为个人资料图片'photo' => ['nullable', 'image', 'max:1024'] 上传的图片大小。

    见下方法:

    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();
        }
    }
    

    【讨论】:

    • 谢谢安德鲁!在此期间找到了相同的文件。 :-) 但是,即使在更改之后,我仍然无法上传 >1MB 的文件。 Buuut,现在我在前端“无法上传”。而不是“文件太大”。所以,我需要检查一下,另一个地方是否有某种限制。不过谢谢!
    • @PierrePetite 可能在.htaccess 文件中设置了限制,这不太可能但值得检查。可能会有这样的值限制你:php_value upload_max_filesize 10Mphp_value post_max_size 20Mphp_value memory_limit 32M
    猜你喜欢
    • 1970-01-01
    • 2014-07-02
    • 2013-07-16
    • 2015-12-31
    • 2019-05-04
    • 2017-07-12
    • 2014-11-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多