php上传大文件报错Internal Server Error,导致文件上传失败。接下来我们就解决这个问题。
Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator at admin@example.com to inform them of the time this error occurred, and the actions you performed just before this error. More information about this error may be available in the server error log. Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.
解决方案
首先修改php.ini 文件
max_execution_time = 600 ;每个PHP页面运行的最大时间值(秒),默认30秒 max_input_time = 600 ;每个PHP页面接收数据所需的最大时间,默认60秒 memory_limit = 8m ;每个PHP页面所吃掉的最大内存,默认8M
把上述参数修改后,在网络所允许的正常情况下,就可以上传大体积文件了
file_uploads = on ;这个很重要,必须要on才可以 upload_max_filesize = 32m ;根据需求改到最大 post_max_size = 32m ;表单提交的最大尺寸 file_uploads = On 这里设置是否允许HTTP上传,默认应该为ON的 upload_tmp_dir= 这里设置上传文件存放的临时位置,必须指定
如果以上配置都做最大修改了,还是报错,那么请再次修改Apache服务器设置
在httpd.conf 文件中添加以下代码段,重启Apache服务问题即可解决。
<IfModule mod_fcgid.c> AddHandler fcgid-script .fcgi # FcgidConnectTimeout 20 # to get around upload errors when uploading images increase the MaxRequestLen size to 15MB MaxRequestLen 157286400000 </IfModule>