为什么我的服务器不接受大于2MB的文件?

时间:2013-02-06 16:38:22

标签: php file-upload asihttprequest vps

我有一台运行XAMPP的VPS,并为我制作的iPhone App提供服务。

我使用 ASIHTTPRequest 将文件上传到服务器。

应用程序将文件发送到服务器,服务器只接受那些比2MB轻的文件。

我还查看了Wireshark并发现了这个警告:

PHP致命错误:第2行中c:/xxx/index.php超出最长执行时间60秒

第2行我写道: session_start();

在我的理论中,它们阻止了大文件进入我的服务器:

  1. 某种文件大小限制
  2. 每次操作的某种时间限制
  3. 我真的需要帮助。谢谢!

4 个答案:

答案 0 :(得分:3)

检查php.ini文件中的以下行:

upload_max_filesize = 2M
max_execution_time = 300

之后您可能必须重新启动服务器。

答案 1 :(得分:2)

检查php.ini文件中的设置,该文件在运行XAMPP时可以在*root*/php/目录中找到。

#Make sure file uploads are turned on
file_uploads = On

#Change the max upload size to 100Mb
upload_max_filesize = 100M

#Change the max post size to 100Mb
post_max_size = 100M

#Change the max upload time to 900seconds
max_input_time = 900

#This is where you are seeing your problem as the script execution is timing out.
#Change the max execution time of the script to 900 seconds
max_execution_time = 900

答案 2 :(得分:0)

错误说明:Maximum execution time of 60 seconds exceeded

这让我认为您的互联网连接速度很慢,因此上传速度超过max_execution_time

查看当前max_execution_time的内容:

$maxtime = ini_get(max_execution_time);

echo $maxtime;

要使当前页面的max_execution_time更大,请在PHP文件的顶部输入以下行: ini_set("max_execution_time", 600);?>

答案 3 :(得分:0)

放入index.php的地形:

<?php
ini_set('max_execution_time', 180); //Put the number of seconds that you want

upload_max_filesize无法在运行时更改,因此您需要在php.ini

中增加此值