【问题标题】:Php file uploading warning messagephp文件上传警告信息
【发布时间】:2012-05-18 20:00:33
【问题描述】:

我需要上传一个视频文件。这是我的代码

 if(($_FILES["file"]["type"]=="application/octet-stream") || ($_FILES["file"]["type"]=="video/x-ms-wmv"))
          {
        if($_FILES["file"]["error"] > 0)
          {
          echo "Error: ".$_FILES["file"]["error"]."<br />";

          }
        else if(file_exists("videos/" . $_FILES["file"]["name"]))
              {
              echo $_FILES["file"]["name"] . " already exists. ";
              }
            else
              {
              move_uploaded_file($_FILES["file"]["tmp_name"],"videos/".$_FILES["file"]["name"]);

        $filename=$_FILES["file"]["name"];  
        $type=$_FILES["file"]["type"];
        $size=($_FILES["file"]["size"]/1024);
        $path="".$_FILES["file"]["name"];
       if(($ins=mysql_query("insert into achieva_video values('','".$_REQUEST['vname']."','".$_REQUEST['courid']."','".$filename."','".$path."','".$size."','".$type."','Active')"))==true)
        {
            header("location:viewcoursevideo.php?ins=1");
        }  
        else
        {
            echo("<script>alert('Failure Please try again later');</script>");
        }
     }
          }

    else
     {
      echo "<script>alert('Invalid File Type');</script>)";

     }

当我尝试上传视频文件时,我对这条警告消息感到有些困惑。

"PHP Warning:  POST Content-Length of 9311816 bytes exceeds the limit of 8388608 bytes in Unknown on line 0"

我在 php ini 中设置了以下首选项:

 memory limit = 150M
  upload file size = 120M 
  post max size = 120M

该文件尚未更新。这需要很长时间,只是显示此警告。

【问题讨论】:

  • 您是否检查了 phpinfo() 以查看是否应用了这些值?
  • 是的。我检查了。一切就绪
  • 您是否尝试将值设置为字节而不是使用 M 表示法
  • 你的意思是像 9311815b 这样的东西?

标签: php file-upload php-ini


【解决方案1】:

消息似乎很清楚:您将上传限制设置为 8M(8388608 字节),并且您正在上传 9M(9311816 字节)的文件。您确定 php.ini 中的这些设置有效吗?

 memory limit = 150M
 upload file size = 120M 
 post max size = 120M

【讨论】:

  • 但我可以在 phpinfo 中看到如上设置的首选项。如何检查工作与否?
  • 问题是你达到了 php 脚本的最大执行时间吗?例如,上传速度很慢,而且需要太多时间。尝试增加 max_execution_time 的值!
  • max_execution_time 设置为 3600s 表示 1hr。
【解决方案2】:

不应该是这样吗? (下划线,最大值!)

memory_limit = 150M
upload_max_filesize = 120M
post_max_size = 120M

【讨论】:

  • 是的,我只是这样设置的
  • 您在共享网络服务器上吗?
  • 是的。它有什么问题?
  • 在共享网络服务器上,您可能有一个无法更改的“主值”。
猜你喜欢
  • 2012-11-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-09-27
  • 2010-11-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多