Home  >  Article  >  php教程  >  php无法上传大文件的解决方法

php无法上传大文件的解决方法

WBOY
WBOYOriginal
2016-06-13 09:41:35896browse

  1. "multipart/form-data"
     action="add_file.php" method="post">  
  2. Fill out the form to upload a file:  
  3. // Create the inputs.  
  4. for ($i = 0; $i 
  5. echo 'File:  . $i . '" />  
  6.   
  7. Description:  cols="40" rows="5">  
  8.   
  9.   
  10. ';  
  11. }  
  12. ?>  
  13.   
  14. "hidden" name="submitted" value="TRUE" />  
  15. [align=center]"submit" name="submit" value="Submit" />[/align]  
  16.   
在实际执行过程中发现上传稍微大一些的文件时,显示File couldn't be moved。 
数据库里显示文件名称,不显示大小。 
而上传大于8M的文件时,页面根本没有反应。 

网上找到几篇文章: 
解决PHP上传大文件的问题 
php设置允许大文件上传的方法 
apache+php上传大文件 
php上传大文件时php.ini的几处设置 

以上文章均指出是因为:php的文件上传受到了php.ini如下设置的影响: 
  1. post_max_size  
  2. upload_max_filesize  
  3. max_execution_time  
  4. memory_limit  
于是,找到 /etc/php5/apache2/,在其下找到php.ini,查找post_max_size,将其默认值修改为125M; 
查找upload_max_filesize,将其默认值修改为125M,然后保存。 
在终端输入:apache2ctl -k restart 重启apache,问题成功解决了。
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn