dongmou5628 2015-07-14 07:03
浏览 51

上传较大的文件到服务器不起作用

I got a problem here about upload larger file in my server.I go through a lot of related questions here but i still got the same problem. I increase all the necessary php.ini in the server and when i upload larger file for only 38MB the system cannot upload it.What i do wrong here. Please help Thanks in advance.

$allowedExts = array("mp4", "MP4");
$extension = pathinfo($_FILES['file']['name'], PATHINFO_EXTENSION);

if ((($_FILES["file"]["type"] == "video/mp4")
|| ($_FILES["file"]["type"] == "video/MP4"))

&& in_array($extension, $allowedExts))

  {
  if ($_FILES["file"]["error"] > 0)
    {
    echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
    }
  else
    {
    echo "Upload: " . $_FILES["file"]["name"] . "<br />";
    echo "Type: " . $_FILES["file"]["type"] . "<br />";
    echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
    echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";

    if (file_exists('/home/hyborg/public_html/vimeo2/upload/' . $_FILES["file"]["name"]))
      {
      echo $_FILES["file"]["name"] . " already exists. ";
      }
    else
      {
      move_uploaded_file($_FILES["file"]["tmp_name"], '/home/hyborg/public_html/vimeo2/upload/' . $_FILES["file"]["name"]);
      echo "Upload Success" . $_FILES["file"]["name"];
      }
    }
  }
else
  {
  echo "Sorry something wrong with your upload";
  }
  • 写回答

1条回答 默认 最新

  • dongshui2254 2015-07-14 07:18
    关注

    Did you make all the appropriate changes? upload_max_filesize and post_max_size

    Also you should change the max_input_time ,as upload.PHP scripts normally time-out after 30 seconds.For larger files to upload it takes much time.Try increasing the max_execution_time to something like 500 (in sec).

    Then you have to define the constraints within your PHP application:

    ini_set('upload_max_filesize', '10M');
    ini_set('post_max_size', '10M');
    ini_set('max_input_time', 300);
    ini_set('max_execution_time', 300);
    

    PHP also provides a set_time_limit() function so you don’t need to set max_execution_time directly.

    Setting the options in your PHP code is possibly more practical, since you can extend the execution time and increase the file size when your application is expecting a large upload.

    评论

报告相同问题?

悬赏问题

  • ¥15 在获取boss直聘的聊天的时候只能获取到前40条聊天数据
  • ¥20 关于URL获取的参数,无法执行二选一查询
  • ¥15 液位控制,当液位超过高限时常开触点59闭合,直到液位低于低限时,断开
  • ¥15 marlin编译错误,如何解决?
  • ¥15 有偿四位数,节约算法和扫描算法
  • ¥15 VUE项目怎么运行,系统打不开
  • ¥50 pointpillars等目标检测算法怎么融合注意力机制
  • ¥20 Vs code Mac系统 PHP Debug调试环境配置
  • ¥60 大一项目课,微信小程序
  • ¥15 求视频摘要youtube和ovp数据集