调整 MediaWiki 上传文件尺寸限制的问题

最近架设了一个基于 MediaWiki 1.17.0 的文档库,由于需要上传文件,调整了一下文件上传尺寸的限制。

我编辑了一下 php.ini,调整了一下 upload_max_filesize。

upload_max_filesize = 10M

在上传文件的页面中可以见到限制已经提供到了 10M,可是上传 8M 左右的文件时就失败了,而且没有任何错误提示。

在查找了有关 php 的文档时发现还有一个参数和上传文件尺寸相关:post_max_size,提升了此参数值后解决问题。

post_max_size = 10M

引用一下官方文档的说明

Files are usually POSTed to the webserver in a format known as 'multipart/form-data'. The post_max_size sets the upper limit on the amount of data that a script can accept in this manner. Ideally this value should be larger than the value that you set for upload_max_filesize.

It's important to realize that upload_max_filesize is the sum of the sizes of all the files that you are uploading. post_max_size is the upload_max_filesize plus the sum of the lengths of all the other fields in the form plus any mime headers that the encoder might include. Since these fields are typically small you can often approximate the upload max size to the post max size.

According to the PHP documentation you can set a MAX_UPLOAD_LIMIT in your HTML form to suggest a limit to the browser. Our understanding is that browsers totally ignore this directive and the only solution that can impose such a client side restriction is our own Rad Upload Applet

Over!

Leave a Reply

Your email address will not be published. Required fields are marked *