laravel - 在 PostTooLargeException laravel 5.6 之后尝试重定向到上一个视图(有错误)
问题描述
**(Laravel 5.6)**在提交带有文件输入的表单后,laravel 抛出 PostTooLargeException,我想重定向回上传视图并显示错误消息。我发现我可以在 Handler.php 方法 render() 中重定向回:
`if ($exception instanceof \Illuminate\Http\Exceptions\PostTooLargeException)
{
return redirect()->back();
}
`
但我想重定向错误,这些错误将显示在上传表单视图中。我已经尝试了下面链接中的所有解决方案,但没有任何效果。
感谢帮助。
这是异常的图像:PostTooLargeException
解决方案
尝试增加 php.ini 文件中的“post_max_size”以避免该异常
对于错误,这应该有效
redirect()->back()->withErrors();
这是一个链接,可以帮助您解决看不到错误的原因。https://laracasts.com/discuss/channels/code-review/redirect-with-errors-not-working?page=1
推荐阅读
- xml - Microsoft Word (OOXML/DOCX) 文档格式验证
- android - 使用edittext的IP地址验证器
- matlab - 根据索引向量切片数据向量
- php - 使用sql按家庭搜索表
- android - 如何在 imageList 上实现 onClickListener
- c - 为什么我只调用一次 fork 会得到多个 SIGCHLD?
- python - 如何滞后熊猫系列并创建新的时间滞后数据框?
- java - 了解失败的 JUnit4 测试?
- python - 我们如何使用 itertools.permutations 以 01012000-31122012 的格式获取日期范围(例如从 Jan 2000 到 Dec 2010 )?
- sql - 插入已知值以及从 JOINS 确定的值