虽然是PHP和Laravel的新手,但仍在与之抗争。我正在Jetstream上使用Laravel 8。现在,在前端的Edit-Section中上传新的个人资料-图片时,前端只接受小于1MB的文件。
检查我的PHP.ini,它设置为100M -所以,正常情况下它应该可以工作。你有什么想法,在哪里可能会有额外的验证或限制?
最佳皮埃尔
发布于 2021-03-24 03:07:12
在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();
}
}https://stackoverflow.com/questions/66769509
复制相似问题