我知道如何使用HTML在用户表单上执行此操作。但是,恶意用户可以通过该表单来调用服务器操作页面并发送异常大的文本。
无论如何都要拒绝来自服务器的此类请求。也许,有一种机制可以提前实现在实际到达之前到达的POST数据的大小,类似于上传大文件。
答案 0 :(得分:2)
编辑php.ini
文件并将最大帖子大小设置为您想要允许的数字(以兆字节为单位)。请记住,你需要它足够长的博客文章,什么不是。
post_max_size = 4M
您应该检查的其他设置是
; Maximum execution time of each script, in seconds
; http://php.net/max-execution-time
; Note: This directive is hardcoded to 0 for the CLI SAPI
max_execution_time = 30
; Maximum amount of time each script may spend parsing request data. It's a good
; idea to limit this time on productions servers in order to eliminate unexpectedly
; long running scripts.
; Note: This directive is hardcoded to -1 for the CLI SAPI
; Default Value: -1 (Unlimited)
; Development Value: 60 (60 seconds)
; Production Value: 60 (60 seconds)
; http://php.net/max-input-time
max_input_time = 60
; Maximum amount of memory a script may consume (128MB)
; http://php.net/memory-limit
memory_limit = 30MB
如果您使用的是Apache或Nginx,您还可以在服务器配置中设置最大请求大小,以便在到达 php之前阻止请求。
答案 1 :(得分:1)
您可以使用Suhosin。 它是PHP的保护系统。在这些设置中,您可以禁止超过一定长度的请求。
答案 2 :(得分:0)
当PHP处理POST数据时,它有点晚了。这在Web服务器级别更好。如果您使用的是Apache,请查看LimitRequestBody指令。