简体   繁体   English

PHP POST内容长度

[英]PHP POST Content-Length

When i uploading file by simple form i've got 当我以简单的形式上传文件时,我已经

Warning: POST Content-Length of 372220927 bytes exceeds the limit of 33554432 bytes in Unknown on line 0 
Notice: Undefined index: file in C:\xampp\htdocs\php_upload\upload_file.php on line 3

I change in php_ini to 20M, my problem is that i want to echo nice msg error about too big file, no such warning. 我将php_ini更改为20M,我的问题是我想回显有关太大文件的msg错误,没有这样的警告。 An error/execption i can try/catch. 我可以尝试/捕获的错误/执行。 Where i can found out about "warning" before call: 在致电前可以找到有关“警告”的地方:

$_FILES["file"]["error"]>0 $ _FILES [ “文件”] [ “错误”]> 0

<form action="upload_file.php" method="post"
<form action="upload_file.php" method="post"
enctype="multipart/form-data">
<label for="file">Filename:</label></br>
<input type="file" name="file" id="file"></br>
<input type="text" name="desc" id="desc"></br>
<input type="submit" name="submit" value="Submit">
</form>

// //

if ($_FILES["file"]["error"]>0)
  {
  echo "Error: " . $_FILES["file"]["error"] . "<br>";
  }
else
  {
  echo "Upload: " . $_FILES["file"]["name"] . "<br>";
  echo "Type: " . $_FILES["file"]["type"] . "<br>";
  echo "Size: " . ($_FILES["file"]["size"] / 1024) . " kB<br>";
  echo "Stored in: " . $_FILES["file"]["tmp_name"];
  }

33554432 bytes = ~32MB 33554432字节=〜32MB

372220927 bytes = ~355MB 372220927字节=〜355MB

You need to set post_max_size and upload_max_filesize to at least 355MB absolute minimum to allow the file to upload. 您需要将post_max_sizeupload_max_filesize设置为至少355MB的绝对最小值,以允许文件上传。

Follow this example on how to setup a PHP file upload form where you set the MAX_FILE_SIZE so that you can error back to user if that limit is exceeded. 请按照此示例说明如何设置一个PHP文件上传表单,在该表单中设置MAX_FILE_SIZE,以便在超出该限制时可以将错误返回给用户。 Check $_FILES['userfile']['error'] to see if it is equal to the constant UPLOAD_ERR_FORM_SIZE indicating that the file was larger than allowed. 检查$_FILES['userfile']['error']以查看其是否等于常量UPLOAD_ERR_FORM_SIZE指示文件大于允许的大小。 Please note in example the warning about what order to place the INPUT fields 请在示例中注意有关放置INPUT字段的顺序的警告

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM