Php 如何更改特定页面的最大上载大小?

Php 如何更改特定页面的最大上载大小?,php,html,Php,Html,好的。。假设我有一个音乐服务,我如何增加该特定页面的最大文件上传大小,以便在选择大文件时不会超时 好的,我知道您可以通过更改 memory_limit = 32M upload_max_filesize = 10M post_max_size = 20M ,但这将全局设置。您可能需要更改网站的最大上载文件大小。例如,您可以设置一个下限,以防止用户将大型文件上载到您的站点。为此,请更改.htaccess文件中的upload_max_filesize和post_max_size指令 要更改PHP脚

好的。。假设我有一个音乐服务,我如何增加该特定页面的最大文件上传大小,以便在选择大文件时不会超时

好的,我知道您可以通过更改

memory_limit = 32M
upload_max_filesize = 10M
post_max_size = 20M

,但这将全局设置。您可能需要更改网站的最大上载文件大小。例如,您可以设置一个下限,以防止用户将大型文件上载到您的站点。为此,请更改.htaccess文件中的upload_max_filesize和post_max_size指令

要更改PHP脚本的最大上载文件大小,请执行以下步骤:

Log in to your account using SSH.
Use a text editor to add the following line to the .htaccess file. Replace xx with the maximum upload file size that you want to set, in megabytes:

php_value upload_max_filesize xxM

Add the following line to the .htaccess file. Replace xx with the maximum HTTP POST file size that you want to set, in megabytes:

php_value post_max_size xxM
将更改保存到.htaccess文件并退出文本编辑器。 要验证新设置是否处于活动状态,请在.htaccess文件所在的同一目录中创建包含以下代码的PHP测试文件:

在web浏览器中加载测试文件,然后搜索指令的名称。“本地值”列应显示在.htaccess文件中指定的新设置

更多细节

有关不同的可用方法,请参阅

您可以使用多个上传页面(取决于您想要设置的上传限制),这些页面存储在不同的目录中,具有不同的.htaccess配置,这将允许您根据上传限制对用户进行分组。

将其添加到您的php中

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

; Must be greater than or equal to upload_max_filesize
post_max_size = 40M

PHP中有ini_设置,它仅为脚本执行更改PHP.ini设置,无需通过.htaccess执行,因为我有vpn的完全服务器访问权限。同样,这将是为我的网站设置的,我不想要。我希望有一些php语法可以为特定的上传程序增加它。我猜不会。对于大于2mb的内存,您为什么不引用-:
; Maximum allowed size for uploaded files.
upload_max_filesize = 40M

; Must be greater than or equal to upload_max_filesize
post_max_size = 40M