Php 文件上载警告帖子内容长度字节超过限制

Php 文件上载警告帖子内容长度字节超过限制,php,javascript,file-upload,localhost,Php,Javascript,File Upload,Localhost,我正在制作一个文件上传系统。用户使用动态下拉列表选择上传位置。这就是我现在面临的问题。 这是我的表格 <form action="uploader.php" method="POST" enctype="multipart/form-data" name="uploads"> <label for="file">Choose a file: </label> <input type="file

我正在制作一个文件上传系统。用户使用动态下拉列表选择上传位置。这就是我现在面临的问题。 这是我的表格

<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>

选择一个文件:


选择部门 计算机科学与工程 电子与通信工程 机械工程

选择学期

选择主题

上传
这是我链接到的另一个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>");
?>

post\u max\u size表示所有文件大小+其他post字段的总和。
post_max_大小应始终大于upload_max_filesize

尝试将立柱最大尺寸设置为26M

增加: 首先检查是否设置了$\u FILES['userfile'],即:

if(!isset($_FILES['userfile'])) 
  die("<SCRIPT LANGUAGE='JavaScript'> 
       window.alert('No file upload !');
       window.location.href='upload.php'; 
      </SCRIPT>");
if(!isset($\u文件['userfile']))
死(”
window.alert('无文件上传!');
window.location.href='upload.php';
");

为什么20000000将大约20mbIt是这部分的答案:“但是当我有意上传大于25MB的文件时,我会得到标题中给出的错误。”顺便说一下,检查是否设置了$_FILES['userfile'],即:
如果(!isset($_FILES['userfile'])死亡(“window alert('No file upload!')window.location.href='upload.php';”;
我在所有检查之前添加了该检查,它将我重定向到空的uploader.php页面,文件不会被上传,但它也不会像我在代码中提到的那样给出错误。还有:解析错误:语法错误,意外的“死”(t_EXIT)在某某路径中,我很抱歉。我的代码中有2个语法错误。在第一行和的末尾应该有“)”符号;JavaScript代码中的分隔符。请参阅编辑的消息