本文介绍了更改最大上传文件大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个无法访问的PC上托管的网站.我有一个上传表格,允许人们上传最大30MB的mp3文件.我的服务器端脚本是用PHP完成的.

I have a website hosted on a PC I have no access to. I have an upload form allowing people to upload mp3 files up to 30MB big. My server side script is done in PHP.

每次尝试上传文件时,都会收到一条错误消息,声称文件超出了允许的最大大小,因此我需要增加大小.我在网上的研究建议更改我无法访问的.htaccess文件,这样将无法正常工作.其他人建议我将自定义php.ini文件添加到我的根目录,该文件无效.还有其他建议吗?

Every time I try and upload a file, I receive an error claiming that the file exceeds the maximum size allowed, so I need to increase the size. My research on the web suggested changing the .htaccess file which I do not have access to, so that won't work. Others suggested that I should add a custom php.ini file to my root which did not work. Any other suggestions?

推荐答案

您需要在php.ini中设置upload_max_filesizepost_max_size的值:

You need to set the value of upload_max_filesize and post_max_size in your php.ini :

; 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文件后,您需要重新启动HTTP服务器以使用新配置.

After modifying php.ini file(s), you need to restart your HTTP server to use new configuration.

如果您无法更改php.ini,那么您就不走运了.您不能在运行时更改这些值.在执行到达您对ini_set的调用时,大于php.ini中指定的值的文件上传将失败.

If you can't change your php.ini, you're out of luck. You cannot change these values at run-time; uploads of file larger than the value specified in php.ini will have failed by the time execution reaches your call to ini_set.

请参见核心php.ini指令的说明.

这篇关于更改最大上传文件大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 06:14
查看更多