apache 更改心脏互联网上的 php.ini 设置
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1680107/
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
changing php.ini settings on heart internet
提问by Abdul Latif
I am trying to upload large files through my cms and was wondering how to change the php.ini file for heart internet.
我正在尝试通过我的 cms 上传大文件,并且想知道如何更改心脏互联网的 php.ini 文件。
Is this possible in shared hosting, if not are there any other work arounds?
这在共享托管中是否可能,如果没有,还有其他解决方法吗?
Thanks in Advance
提前致谢
采纳答案by Salman A
It depends on whether your web hosting company allows you to overridecertain PHP settings or not. It might be possible to change some values but not others.
这取决于您的网络托管公司是否允许您覆盖某些 PHP 设置。可能可以更改某些值,但不能更改其他值。
Secondly, the process for overriding settings differs depending on whether your hosting is IIS or Apache. If its Apache, try adding these two lines to your .htaccess file:
其次,覆盖设置的过程因您的主机是 IIS 还是 Apache 而异。如果是 Apache,请尝试将这两行添加到您的 .htaccess 文件中:
php_value upload_max_filesize 8M
php_value post_max_size 8M
This .htaccess file should do to the directory where your php upload script resides, or higher. I'd rather put it in the root directory.
这个 .htaccess 文件应该处理你的 php 上传脚本所在的目录,或者更高。我宁愿把它放在根目录中。
Once done, create a php page containing this code:
完成后,创建一个包含以下代码的 php 页面:
<?php phpinfo( ); ?>
Compare the Local Value and Master Value of these settings to see if the changes are in effect.
比较这些设置的本地值和主值以查看更改是否生效。
回答by Fenton
To override settings all you need to do is create either a php.ini or php5.ini file (if you are running PHP5) in your root directory. Then you can change settings like this:
要覆盖设置,您只需在根目录中创建一个 php.ini 或 php5.ini 文件(如果您正在运行 PHP5)。然后你可以像这样更改设置:
upload_max_filesize = 20M ;
post_max_size = 20M ;
max_execution_time = 60 ;
This gives you maximum file size of 20MB and 60 second timeout.
这为您提供了 20MB 的最大文件大小和 60 秒超时。
As long as you keep this size within the allowed limits on your account, you can use this to increase the default size - which is 5MB.
只要您将此大小保持在帐户允许的限制范围内,您就可以使用它来增加默认大小 - 5MB。
回答by Andrew
There is no way to upload files over 50MB without breaking your terms and getting your account shutdown.
上传超过 50MB 的文件时无法违反条款并关闭您的帐户。
However if the terms were different, you could split the file into parts and join them together on the server side.
但是,如果条款不同,您可以将文件拆分为多个部分,然后在服务器端将它们连接在一起。
I moved away from heart internet and got my own server for this exact reason as they wouldn't even let me pay a premium to get the restriction removed (restricted from there end I think)
由于这个确切的原因,我离开了心脏互联网并拥有了自己的服务器,因为他们甚至不会让我支付额外费用来取消限制(我认为从那里开始限制)
回答by Ben Everard
If it is shared hosting you probably won't be able to, I have also discovered that you cannot use ini_set to set the correct settings because the file upload occurs before your script is executed. So if you want to accept large files via a form to a PHP script you have to use php.ini.
如果它是共享主机,您可能无法使用,我还发现您无法使用 ini_set 来设置正确的设置,因为文件上传发生在您的脚本执行之前。所以如果你想通过表单接受大文件到 PHP 脚本,你必须使用 php.ini。
You might be a work around though, you could use an open FTP account, upload large files form there and code a bit of script to ask the user what file they have uploaded, then you can manipulate (move / rename) to your hearts content.
不过,您可能是一个解决方法,您可以使用一个开放的 FTP 帐户,从那里上传大文件并编写一些脚本来询问用户他们上传了什么文件,然后您可以操作(移动/重命名)您的心内容.

