本文介绍了使用PHP上传大文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  

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


以下是我的代码:

  $ query =update tbl_Cards set CardName ='$ cardname',Description ='$ Description'; 
if($ cardvideo)
{
if($ _ FILES [cardvideo] [type] ==video / quicktime|| $ _FILES [cardvideo] [键入] ==video / mov|| $ _FILES [cardvideo] [type] ==video / mp4|| $ _FILES [cardvideo] [type] ==video / ($ _ FILES [cardvideo] [size]< = fvv|| $ _FILES [cardvideo] [type] ==video / 3gp)
{ 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();但是当我上传10 MB的文件,他们成功上传,但当我尝试上传大的文件(20或30或40或50)我得到这个响应:

pre $ 列计数不匹配行计数值

我做错了什么?

解决方案

它不仅仅是php.ini,而且服务器也可以限制你的请求大小。虽然在默认情况下在Apache中没有设置限制文件大小,但我认为你应该检查一下。 LimitRequestBody指令用于限制请求大小。检查所有配置文件中的指令(我假设你使用的是Apache)并更改你的目录的值。
示例用法:

$ p $ <目录/ var / www / vhost / mydir / uploads>
LimitRequestBody 204444344
< / Directory>


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?

解决方案

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>

这篇关于使用PHP上传大文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-05 05:32