laravel - Laravel Jetstream 照片最大尺寸
问题描述
PHP 和 Laravel 的新手,但正在努力克服它。我正在使用带有 Jetstream 的 Laravel 8。现在,在前端的编辑部分中上传新的个人资料图片时,前端只接受 <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();
}
}
推荐阅读
- javascript - React:将方法推送到父组件的替代方案
- google-spreadsheet-api - 使用javascript获取带有工作表api的单元格的谷歌工作表下拉值
- python - Pycharm 和 Django:ImportError:没有名为“local_settings”的模块
- python - 在没有符号的熊猫上连接两个数据帧,只有日期(来自 pd.datareader)
- lucene - Lucene 查询数组和“IN”、“ALL IN”、“ANY IN”操作
- parsing - Filemaker if 语句不起作用
- c++ - 如何仅将部分 OpenGL 代码实现到使用 SDL 编写的游戏中?
- c# - 如何防止 C# WPF 应用程序启动其他应用程序两次?
- git - Jenkins 中的主机密钥验证失败,在 Docker 中工作
- android - AdMob 欧盟用户意见征求政策