简体   繁体   English

文件上载警告发布内容的字节长度超出限制

[英]File Upload Warning post content-length of bytes exceeds the limit

I am making a file upload system. 我正在制作文件上传系统。 The user chooses where to upload using the dynamic drop down list. 用户使用动态下拉列表选择上传位置。 And this is the problem I am facing right now. 这就是我现在面临的问题。 This is my form. 这是我的表格。

<form action="uploader.php" method="POST" enctype="multipart/form-data" name="uploads">

            <label for="file">Choose a file: </label> 

                <input type="file" name="userfile" id="userfile"><br/><br/>

                    <select id="text-one" name="one"> 

                        <option selected value="base">Select Department</option>
                        <option value="CSE" name="cse">Computer Science Engineering</option>
                        <option value="ECE" name="ece">Electronics & Communication Engineering</option>
                        <option value="MECH" name="mech">Mechanical Engineering</option>

                    </select>

                    <br /><br/>

                    <select id="text-two" name="two">
                        <option>Select Semester</option>
                    </select>

                    <br /><br/>

                    <select id="text-three" name="three">
                        <option>Select Subject</option>
                    </select>

                    <br/><br/>

            <button class ="btn btn-primary" button type="submit" name="upload" value="Upload" onClick="val()">Upload</button>

        </form>

And this is my other php file to which it is linked. 这是我链接到的其他php文件。

<?php
if(isset($_POST['upload']))
{ 
  $path1=$_POST['one']."/"; 
  $path2=$_POST['two']."/"; 
  $path3=$_POST['three']."/";   
  $upload_path=$path1.$path2.$path3;
 }
else
 {
  echo "Select a Subject";
  echo "<br>";
}
$allowed_filetypes = array('.doc','.docx','.jpg','.jpeg','.png','.ppt','.pptx','.xls','.xlsx','.pdf','.txt','.zip','.rar'); 
$max_filesize = 20000000; 
$filename = $_FILES['userfile']['name']; 
$ext = substr($filename, strpos($filename,'.'), strlen($filename)-1);
if(!in_array($ext,$allowed_filetypes))
  die("<SCRIPT LANGUAGE='JavaScript'>
        window.alert('You cannot upload the following type of file!')
        window.location.href='upload.php';
     </SCRIPT>");
if(filesize($_FILES['userfile']['size']) > $max_filesize)
  die("<SCRIPT LANGUAGE='JavaScript'>
        window.alert('The file you attempted to upload is too large!')
        window.location.href='upload.php';
     </SCRIPT>");
if(!is_writable($upload_path))
  die("<SCRIPT LANGUAGE='JavaScript'>
        window.alert('You cannot upload to the specified directory!')
        window.location.href='upload.php';
     </SCRIPT>");
if(move_uploaded_file($_FILES['userfile']['tmp_name'],$upload_path . $filename))
  echo ("<SCRIPT LANGUAGE='JavaScript'>
          window.alert('Your file has been uploaded successfully')
          window.location.href='upload.php';
        </SCRIPT>");
else
  echo ("<SCRIPT LANGUAGE='JavaScript'>
          window.alert('There was an error during the file upload!')
          window.location.href='upload.php';
        </SCRIPT>");
?>

I have edited the phpini file with the following settings and also made a .htaccess file in the php folder. 我已经使用以下设置编辑了phpini文件,并且还在php文件夹中创建了一个.htaccess文件。

upload_max_filesize 25M post_max_size 25M memory_limit 64M upload_max_filesize 25M post_max_size 25M memory_limit 64M

But when I intentionally upload a file greater than 25 MB, I get the error as given in the title. 但是,当我有意上传大于25 MB的文件时,出现标题中给出的错误。 Also, considering the max file size is being violated, it does not give the error related to the file size, ie The file you attempted to upload is too large, it says You cannot upload the following type of file. 另外,考虑到最大文件大小被违反,它不会给出与文件大小有关的错误,即,您尝试上传的文件太大,它表示您无法上传以下类型的文件。 And in the background that post length warning thing comes. 并在后台发出帖子长度警告事件。

Please help me with this. 请帮我解决一下这个。 I am on my localhost. 我在本地主机上。

post_max_size means sum of all filesizes + other post fields. post_max_size表示所有文件大小加上其他post字段的总和。
post_max_size should be always more than upload_max_filesize post_max_size应始终大于upload_max_filesize

Try to set post_max_size as 26M 尝试将post_max_size设置为26M

Added: Firs of all check if $_FILES['userfile'] is set ie: 补充:首先检查是否设置了$ _FILES ['userfile'],即:

if(!isset($_FILES['userfile'])) 
  die("<SCRIPT LANGUAGE='JavaScript'> 
       window.alert('No file upload !');
       window.location.href='upload.php'; 
      </SCRIPT>");

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 处理得很好“POST内容 - 字节长度超过”警告限制 - Handle nicely “POST Content-Length of bytes exceeds the limit of” warning 无法在服务器上上传文件-错误是警告:超过42669632字节的POST内容长度 - unable to upload a file on Server - error is Warning: POST Content-Length of 42669632 bytes exceeds 警告:90612004 字节的 POST Content-Length 超出了第 0 行未知中 8388608 字节的限制 - Warning: POST Content-Length of 90612004 bytes exceeds the limit of 8388608 bytes in Unknown on line 0 如何避免:警告:POST内容长度47820076字节超过了第0行的Unknown中的8388608字节限制 - How to avoid: Warning: POST Content-Length of 47820076 bytes exceeds the limit of 8388608 bytes in Unknown on line 0 PHP 警告:8978294 字节的 POST 内容长度超出第 0 行未知中 8388608 字节的限制 - PHP Warning: POST Content-Length of 8978294 bytes exceeds the limit of 8388608 bytes in Unknown on line 0 PHP 警告:8412174 字节的 POST Content-Length 超出了 Unknow 中 8388608 字节的限制 - PHP Warning: POST Content-Length of 8412174 bytes exceeds the limit of 8388608 bytes in Unknow 警告:11394639字节的POST内容长度超过了8388608字节的限制 - Warning: POST Content-Length of 11394639 bytes exceeds the limit of 8388608 bytes 警告:POST Content-Length的25447804字节超出了第0行上Unknown中的8388608字节的限制 - Warning: POST Content-Length of 25447804 bytes exceeds the limit of 8388608 bytes in Unknown on line 0 PHP 警告:未知:68 字节的 POST 内容长度超过第 0 行未知中 10 字节的限制, - PHP Warning: Unknown: POST Content-Length of 68 bytes exceeds the limit of 10 bytes in Unknown on line 0, PHP警告:53160843字节的POST内容长度超过了行0上“未知”中的33554432字节的限制 - PHP Warning: POST Content-Length of 53160843 bytes exceeds the limit of 33554432 bytes in Unknown on line 0
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM