Upload Large Files using php?

2019-09-02 10:18发布

I need to upload a large file (up to 190mb) Here is server details for limit:

memory_limit = 50M
post_max_size = 192M
file_uploads = On
upload_max_filesize = 192M 
max_execution_time = 1800 sec
max_input_time = 1800 sec

Here is my code:

 $query="update tbl_Cards set CardName='$cardname',Description='$Description'";
    if($cardvideo)
    {
      if($_FILES["cardvideo"]["type"] == "video/quicktime"||$_FILES["cardvideo"]["type"] == "video/mov"||$_FILES["cardvideo"]["type"] == "video/mp4"||$_FILES["cardvideo"]["type"] == "video/mpv"||$_FILES["cardvideo"]["type"] == "video/3gp")
      {
        if($_FILES["cardvideo"]["size"]<=10485760)
        {
          $cardvideo=$date."card.mp4";
          $tmppath3="services/video/".$cardvideo;
          if(move_uploaded_file($_FILES['cardvideo']['tmp_name'],$tmppath3))
          {
          $thumb=$date.".jpg";
          $thumbDirectory="services/VideoCapturePic/";
          exec("convert \"{$tmppath3}[0]\" -colorspace RGB -geometry 200 $thumbDirectory$thumb");
          $query.=",Video='$cardvideo',CapturePic='$thumb'";
        }
        $query.="where CardId='$card'";

        $result=mysql_query($query);
        if($result)
        {
        } else
        {
        echo mysql_error();
        }

But when I upload 10 mb files they upload successfully but when I try to upload large files (20 or 30 or 40 or 50) I get this response:

Column count doesn't match value count at row

What am I doing wrong?

1条回答
▲ chillily
2楼-- · 2019-09-02 10:57

Its not just the php.ini, but server also can restrict your request size. Though by default in apache its not set to limit the file size, but I think you should check for that once. LimitRequestBody directive is used to restrict the request size. Check for the directive in all your configuration files (I am assuming that you are using apache) and change the value for your directory. Sample usage:

<Directory "/var/www/vhost/mydir/uploads">
    LimitRequestBody 204444344
</Directory>
查看更多
登录 后发表回答