Laravel 5.1最大图像大小
我使用的是Laravel5.1和PHP7。 我尝试实现一个图像上传。大型图像无法上载。(白色屏幕显示,没有错误消息)我在xampp和Web空间上本地测试了它。 对于小图像,它可以工作。 它失败,图像为2.5MB,但最大值为5000 我的控制器:Laravel 5.1最大图像大小,laravel,laravel-5,laravel-5.1,Laravel,Laravel 5,Laravel 5.1,我使用的是Laravel5.1和PHP7。 我尝试实现一个图像上传。大型图像无法上载。(白色屏幕显示,没有错误消息)我在xampp和Web空间上本地测试了它。 对于小图像,它可以工作。 它失败,图像为2.5MB,但最大值为5000 我的控制器: public function fileUpload(Request $request) { if($request->hasfile('filename')) { foreach($request->
public function fileUpload(Request $request)
{
if($request->hasfile('filename'))
{
foreach($request->file('filename') as $image)
{
$targetFolder = public_path().'/images/';
$name=$image->getClientOriginalName();
$extension = $image->getClientOriginalExtension(); // add
$picture = sha1($name . time()) . '.' . $extension; //add
$image->move($targetFolder, $picture);
$image = \Intervention\Image\Facades\Image::make(sprintf('images/%s', $picture))->resize(640, null, function ($constraint) {
$constraint->aspectRatio();
});
$image->sharpen(10);
$image->save();
$form= new Image();
$form->filename = $picture;
$form->appartement_id = $appartement->id;
$form->save();
}
}
return back()->with('success', 'Your images has been successfully');
}
问题是:
根据我的phpinfo文件,我定义了以下值:(xampp上的本地值) 在我的网站上,每一个都是200米。
此值应该足够高?请检查服务器配置好吗?
PHP-
NGINX-
由于它可以处理较小的文件,我猜这与您的PHP配置有关,而不是与您的代码有关。您应该确保PHP.ini中的这两个设置都足够大(您可以更改值以满足您的需要)
您可以运行phpinfo()函数来确认服务器的当前设置,并确保更改成功。首先,您必须根据建议增加php.ini中的值,例如:
upload_max_filesize = 24M
post_max_size = 32M
在laravel验证文件中,大小对应于文件大小(以KB为单位)。
检查
试用控制器
return redirect()->back()->with('success', ['your message,here']);
在我的本地计算机上,它们是post_max_size=8M,upload_max_filesize=10M。在我的Web空间上,每个都是200M。还有其他想法吗?在我的本地计算机上,它们是post_max_size=8M,upload_max_filesize=10M。在我的Web空间上,每个都是200M。还有其他想法吗?试试
return redirect()->back()
chek mu updated answerreturn redirect()->back()->()不会改变任何事情
upload_max_filesize = 24M
post_max_size = 32M
return redirect()->back()->with('success', ['your message,here']);