Laravel Jetstream 照片最大尺寸
Laravel Jetstream Photo Max Size
PHP 和 Laravel 的新手,但努力克服它。我正在使用 Laravel 8 和 Jetstream。现在,当在前端的编辑部分上传新的个人资料图片时,前端只接受 <1MB 的文件。
检查了我的 PHP.ini,它设置为 100M - 所以,通常它应该可以工作。知道哪里可能有额外的验证或限制吗?
最佳
皮埃尔
在 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();
}
}
PHP 和 Laravel 的新手,但努力克服它。我正在使用 Laravel 8 和 Jetstream。现在,当在前端的编辑部分上传新的个人资料图片时,前端只接受 <1MB 的文件。
检查了我的 PHP.ini,它设置为 100M - 所以,通常它应该可以工作。知道哪里可能有额外的验证或限制吗?
最佳 皮埃尔
在 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();
}
}