解决php无法上传大文件问题

  正在做一个文件上传共享网站,想通过以下代码实现文件上传功能:

 

1 <form enctype="multipart/form-data" action="add_file.php" method="post">
2
3 <fieldset><legend>Fill out the form to upload a file:</legend>
4
5 <?php // Create the inputs.
6 for ($i = 0; $i < $counter; $i++) {
7 echo '<p><b>File:</b> <input type="file" name="upload' . $i . '" /></p>
8 <p><b>Description:</b> <textarea name="description' . $i . '" cols="40" rows="5"></textarea></p><br />
9 ';
10 }
11 ?>
12
13 </fieldset>
14 <input type="hidden" name="submitted" value="TRUE" />
15 <div align="center"><input type="submit" name="submit" value="Submit" /></div>
16
17  </form>

 

 

  却发现上传稍微大一些的文件时,显示File couldn't be moved.但是数据库里显示文件名称,不显示大小。而上传大于8M的文件时,页面根本没有反应。上网搜了一下,在飞诺网找到一篇关于“PHP上传问题总结“的文章。文章指出了php的文件上传受到了php.ini以下设置的影响:

  • post_max_size
  • upload_max_filesize
  • max_execution_time
  • memory_limit

  于是到 /etc/php5/apache2/ 下找到了php.ini,搜索post_max_size 将其默认值改为了125M,搜索upload_max_filesize将其默认值改为了125M,保存后。在终端输入:apache2ctl -k restart 重新启动apache,问题解决!可以在页面中随便上传大文件了~

 

参考文献:PHP上传问题总结(文件大小检测,大文件上传)

posted on 2010-05-15 01:08  Candyroot  阅读(2844)  评论(15编辑  收藏  举报