我正在使用Codeigniter,我在上传太大图片时遇到问题,即图片大小比服务器中的upload_max_filesize大。
我想为用户显示自定义消息,而不是此消息:
警告:POST内容长度36276449字节超过了第0行的Unknown中的8388608字节限制
不允许您请求的操作。
答案 0 :(得分:0)
在将图像上传到服务器时,您必须验证,如果图像大小低于某个MB,则允许在服务器上传,否则会抛出验证错误。
您可以使用jQuery validate插件来执行此操作,这是您可以使用它的参考。 Validate file extension and size before submitting form
答案 1 :(得分:0)
也许(如果您是服务器管理员),您可以增加最大邮件大小(Increasing the maximum post size),然后检查大小并通过codeigniter显示消息:
$config['max_size'] = 100;
...
$this->load->library('upload', $config);
if (!$this->upload->do_upload('userfile'))
{
//handle the error with $this->upload->display_errors()
}