开发一个文件上传共享网站,曾想使用下面的代码实现文件上传的功能:
在实际执行过程中发现上传稍微大一些的文件时,显示File couldn't be moved。
数据库里显示文件名称,不显示大小。
而上传大于8M的文件时,页面根本没有反应。
网上找到几篇文章:
[url=http://www.jbxue.com/article/3275.html]解决PHP上传大文件的问题[/url]
[url=http://www.jbxue.com/article/2948.html]php设置允许大文件上传的方法[/url]
[url=http://www.cnblogs.com/LiveStar/archive/2008/08/13/1267346.html]apache+php上传大文件[/url]
[url=http://www.cnblogs.com/ericyuan/archive/2012/10/17/2727138.html]php上传大文件时php.ini的几处设置[/url]
以上文章均指出是因为:php的文件上传受到了php.ini如下设置的影响:
于是,找到 /etc/php5/apache2/,在其下找到php.ini,查找post_max_size,将其默认值修改为125M;
查找upload_max_filesize,将其默认值修改为125M,然后保存。
在终端输入:apache2ctl -k restart 重启apache,问题成功解决了。
<form enctype="multipart/form-data" action="add_file.php" method="post">
<fieldset><legend>Fill out the form to upload a file:</legend>
<?php // Create the inputs.
for ($i = 0; $i < $counter; $i++) {
echo '<b>File:</b> <input type="file" name="upload' . $i . '" />
<b>Description:</b> <textarea name="description' . $i . '" cols="40" rows="5"></textarea>
';
}
?>
</fieldset>
<input type="hidden" name="submitted" value="TRUE" />
[align=center]<input type="submit" name="submit" value="Submit" />[/align]
</form>
在实际执行过程中发现上传稍微大一些的文件时,显示File couldn't be moved。
数据库里显示文件名称,不显示大小。
而上传大于8M的文件时,页面根本没有反应。
网上找到几篇文章:
[url=http://www.jbxue.com/article/3275.html]解决PHP上传大文件的问题[/url]
[url=http://www.jbxue.com/article/2948.html]php设置允许大文件上传的方法[/url]
[url=http://www.cnblogs.com/LiveStar/archive/2008/08/13/1267346.html]apache+php上传大文件[/url]
[url=http://www.cnblogs.com/ericyuan/archive/2012/10/17/2727138.html]php上传大文件时php.ini的几处设置[/url]
以上文章均指出是因为: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,问题成功解决了。