php 如何在.htaccess 中设置upload_max_filesize?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2992376/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to set upload_max_filesize in .htaccess?
提问by T1000
I have try to put theese 2 lines
我试着把这些 2 行
php_value post_max_size 30M
php_value upload_max_filesize 30M
in my root .htaccess file but that brings me "internal server error" message ...
php5 is running on the server
I don't have access to php.ini so i think htaccess is my only chance.
Can you tell me where is the mistake?
Thanks in advance
在我的根 .htaccess 文件中,但这给我带来了“内部服务器错误”消息......
php5 正在服务器上运行
我无权访问 php.ini 所以我认为 htaccess 是我唯一的机会。
你能告诉我错误在哪里吗?
提前致谢
回答by Kerry Jones
php_value upload_max_filesize 30Mis correct.
php_value upload_max_filesize 30M是正确的。
You will have to contact your hosters -- some don't allow you to change values in php.ini
您将不得不联系您的托管商——有些不允许您更改 php.ini 中的值
回答by dev-null-dweller
If you are getting 500 - Internal server errorthat means you don't have permission to set these values by .htaccess. You have to contact your web server providers and ask to set AllowOverride Optionsfor your host or to put these lines in their virtual host configuration file.
如果您收到500 - 内部服务器错误,则意味着您无权通过.htaccess设置这些值。您必须联系您的 Web 服务器提供商并要求AllowOverride Options为您的主机设置或将这些行放在他们的虚拟主机配置文件中。
回答by VAPP Group
php_value memory_limit 30M
php_value post_max_size 100M
php_value upload_max_filesize 30M
Use all 3 in .htaccessafter everything at last line. php_value post_max_sizemust be more than than the remaining two.
.htaccess在最后一行的所有内容之后使用所有 3 。php_value post_max_size必须多于剩下的两个。
回答by Shaishav Shah
What to do to correct this is create a file called php.ini and save it in the same location as your .htaccess file and enter the following code instead:
解决这个问题的方法是创建一个名为 php.ini 的文件并将其保存在与 .htaccess 文件相同的位置,然后输入以下代码:
upload_max_filesize = "250M"
post_max_size = "250M"
回答by PCTuneUpGuy
If your web server is running php5, I believe you must use php5_value. This resolved the same error I received when using php_value.
如果您的 Web 服务器正在运行 php5,我相信您必须使用php5_value. 这解决了我在使用php_value.
回答by afshin
Both commands are correct
两个命令都是正确的
php_value post_max_size 30M
php_value upload_max_filesize 30M
BUT to use the .htaccessyou have to enable rewrite_modulein Apache config file. In httpd.conffind this line:
但是要使用.htaccess您必须rewrite_module在 Apache 配置文件中启用。在httpd.conf找到这一行:
# LoadModule rewrite_module modules/mod_rewrite.so
and remove the #.
并删除#.

