能够上传28兆字节的文件,但php.ini将帖子限制为10兆。这是什么? [英] able to upload 28 meg file, yet php.ini limits posts to 10 megs.What is up with that?

查看:84
本文介绍了能够上传28兆字节的文件,但php.ini将帖子限制为10兆。这是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



为了防止我们的用户可能上传大文件,我的php.ini文件中有这个




; PHP将接受的最大POST数据大小。

post_max_size = 10M

在运行Ubuntu Linux的服务器上。 PHP版本:


root @ ldc310:/ etc / php5 / cli #php -v

PHP 5.1.6(cli)(内置:11月28日) 2007 22:52:49)


我刚刚将28兆字节的文件上传到服务器。我有一个PHP脚本,

自动将图像大小调整到小于1亿。但是,我假设上传应该失败,在PHP脚本之前

有机会调整文件大小,我就是

。如何限制用户上传
的费用?我真的不希望用户有权上传30或

40或50 meg文件。


服务器确实安装了Plesk,我知道,在过去的时间里,已经找到了破坏php.ini设置的方法。例如,对于

open_basedir,在httpd.conf文件中写入的值,每个vhost目录在
中,优先于我在php.ini中放置的值。

但我从来没有见过Plesk破坏了post_max_size

设置的重要性,我也无法想象Plesk可能存储这样的conf设置

如果确实如此。


对可能出现的问题有什么想法?是否有其他地方有些

配置数据可能是先例?

解决方案

5月30日晚上7:01, Lawrence Krubner< lawre ... @ krubner.comwrote:


>

为防止我们的用户可能上传大文件,我'$

在我的php.ini文件中得到了这个:


; PHP将接受的最大POST数据大小。

post_max_size = 10M



upload_max_filesize怎么样?什么,如果有的话,是什么,在Apache设置为?b $ b LimitRequestBody指令?是否有任何.htaccess

文件可能会改变这些?


当我们正在检查可能性时,你是否正在编辑

php.ini PHP正在使用?


另外,你是在运行PHP作为Apache模块还是CGI / FastCGI?


干杯,

NC


NC写道:


5月30,7:01 pm,Lawrence Krubner< lawre ... @ krubner.comwrote:


>为防止我们的用户上传大文件,我' '
在我的php.ini文件中得到了这个:

; PHP将接受的最大POST数据大小。
post_max_size = 10M



upload_max_filesize怎么样?



来自我的php.ini文件:


;上传文件的最大允许大小。

upload_max_filesize = 10M


什么,如果有的话,是

Apache中的LimitRequestBody指令设置为?



这什么都不返回:


root @ ldc310:〜#cd / etc / apache2 /

root @ ldc310:/ etc / apache2#grep -R LimitRequestBody *


所以我认为它没有设置。


是否有任何.htaccess

文件可能会改变这些?



不,不在上传脚本所在网站的顶层。


虽然我们正在检查可能性,你是否正在编辑相同的

php.ini PHP正在使用?



我假设,但我怎么能确定?这告诉我版本:

root @ ldc310:/ var / www / vhosts / thesecondroad。 org / httpdocs #php -v

PHP 5.1.6(cli)(建于:2007年11月28日22:52:49)


由于它是PHP版本5,我认为这是正确的编辑路径:


root @ ldc310:/ #nano /etc/php5/cli/php.ini


我能肯定的任何方式吗?我如何检查?


此外,您是否将PHP作为Apache模块或CGI / FastCGI运行?



Apache模块。


- 劳伦斯

5月31日上午12:04,Lawrence Krubner< lawre ... @ krubner.comwrote:


NC写道:
< blockquote class =post_quotes>
什么,如果有的话,是LimitRequestBody指令

在Apache中设置为?



这什么都不返回:


root @ ldc310:〜#cd / etc / apache2 /

root @ ldc310:/ etc / apache2#grep -R LimitRequestBody *


所以我认为它没有设置。



如果没有设置,它将采用默认值零(意味着,没有

限制)。


当我们正在检查可能性时,你是否正在编辑

PHP使用相同的php.ini ?



我假设,但我怎么能确定?



从浏览器运行phpinfo(),而不是从命令行运行。寻找

配置文件(php.ini)路径在输出中。命令行

解释器,服务器模块和CGI / FastCGI可执行文件可以

每个都有不同的php.ini ...


因为它是PHP版本5,我认为这是

编辑的正确途径:


root @ ldc310: / #nano /etc/php5/cli/php.ini



我不这么认为;请注意cli。在路上。看起来你是在编辑命令行解释器使用的php.ini,

不是Apache模块使用的那个。 />


我能肯定的任何方式吗?我该如何检查?



见上面phpinfo()上的位。


干杯,

NC


To guard against our users possibly uploading huge files, I''ve got this
in my php.ini file:

; Maximum size of POST data that PHP will accept.
post_max_size = 10M
On a server running Ubuntu Linux. The PHP version:

root@ldc310:/etc/php5/cli# php -v
PHP 5.1.6 (cli) (built: Nov 28 2007 22:52:49)

I just uploaded a 28 meg file to the server. I have a PHP script that
automatically resizes the images to less than a meg. However, I was
assuming that the upload should have failed, before the PHP script ever
had the chance to resize the file. How do I limit how much our users can
upload? I really don''t want the users to have the power to upload 30 or
40 or 50 meg files.

The server does have Plesk installed, which I know, in times past, has
found ways to undermine the settings in php.ini. For instance, for
open_basedir, the value that gets written in the httpd.conf file, in
each vhost directory, takes precedence over whatever I put in php.ini.
But I''ve never seen Plesk undermine the importance of the post_max_size
setting, nor can I imagine where Plesk might store such a conf setting
if it did.

Any thoughts on what might be wrong? Are there other places some
configuration data might be taking precedent?

解决方案

On May 30, 7:01 pm, Lawrence Krubner <lawre...@krubner.comwrote:

>
To guard against our users possibly uploading huge files, I''ve
got this in my php.ini file:

; Maximum size of POST data that PHP will accept.
post_max_size = 10M

What about upload_max_filesize? And what, if anything, is
LimitRequestBody directive in Apache set to? Are there any .htaccess
files that could possibly change any of this?

And while we''re checking for possibilities, are you editing the same
php.ini PHP is using?

Also, are you running PHP as an Apache module or CGI/FastCGI?

Cheers,
NC


NC wrote:

On May 30, 7:01 pm, Lawrence Krubner <lawre...@krubner.comwrote:

>To guard against our users possibly uploading huge files, I''ve
got this in my php.ini file:

; Maximum size of POST data that PHP will accept.
post_max_size = 10M


What about upload_max_filesize?


From my php.ini file:

; Maximum allowed size for uploaded files.
upload_max_filesize = 10M

And what, if anything, is
LimitRequestBody directive in Apache set to?

This returns nothing:

root@ldc310:~# cd /etc/apache2/
root@ldc310:/etc/apache2# grep -R LimitRequestBody *

So I assume it is not set.

Are there any .htaccess
files that could possibly change any of this?

No, not at the top level of the site, where the upload script is.

And while we''re checking for possibilities, are you editing the same
php.ini PHP is using?

I assume, but how could I be sure? This tells me the version:

root@ldc310:/var/www/vhosts/thesecondroad.org/httpdocs# php -v
PHP 5.1.6 (cli) (built: Nov 28 2007 22:52:49)

Since it is PHP version 5, I assume this is the right path for editing:

root@ldc310:/# nano /etc/php5/cli/php.ini

Any way I can be sure? How do I check?

Also, are you running PHP as an Apache module or CGI/FastCGI?

An Apache module.

-- lawrence


On May 31, 12:04 am, Lawrence Krubner <lawre...@krubner.comwrote:

NC wrote:

And what, if anything, is LimitRequestBody directive
in Apache set to?


This returns nothing:

root@ldc310:~# cd /etc/apache2/
root@ldc310:/etc/apache2# grep -R LimitRequestBody *

So I assume it is not set.

And if it''s not set, it takes the default value, zero (meaning, no
limit).

And while we''re checking for possibilities, are you editing
the same php.ini PHP is using?


I assume, but how could I be sure?

Run phpinfo() FROM THE BROWSER, not from command line. Look for
"Configuration File (php.ini) Path" in the output. The command-line
interpreter, the server module, and the CGI/FastCGI executable can
each have a different php.ini...

Since it is PHP version 5, I assume this is the right path for
editing:

root@ldc310:/# nano /etc/php5/cli/php.ini

I don''t think so; note the "cli" in the path. Looks like you''re
editing the php.ini that''s used by the command-line interpreter,
not the one used by the Apache module.

Any way I can be sure? How do I check?

See the bit on phpinfo() above.

Cheers,
NC


这篇关于能够上传28兆字节的文件,但php.ini将帖子限制为10兆。这是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆