简体   繁体   English

一个if语句,即使它应该返回false,也始终返回true

[英]An if statement that always returns true even when it should return false

I've seen many references in many forums to this statement in regards to uploading files 我在很多论坛上都看到过很多关于上传文件的参考。

if ($_FILES["file"]["size"] < 20000) 

Yet when I use this, it seems that no matter what the size of the file being uploaded, this always returns true. 但是,当我使用此功能时,无论上传的文件大小如何,它始终返回true。 I have placed echo statements like these to try to determine what is going on 我已经放置了像这样的echo语句来尝试确定正在发生什么

if ($_FILES["file"]["size"] < 20000) {
   echo "The file size (".$_FILES["file"]["size"].") is smaller than 20000" ;}
  else {
     echo "The file size (".$_FILES["file"]["size"].") is larger than 20000" ;}

and what I will get echoed is something like "The file size (2000000) is smaller than 20000" and never will I see "The file size (2000000) is larger than 20000" regardless of the size of the uploaded file 我会得到类似“文件大小(2000000)小于20000”的提示 ,而无论上传的文件大小如何,我都永远不会看到“文件大小(2000000)大于20000”

Any help would be much appreciated.... 任何帮助将非常感激....

Thanks to all who responded, my problem turned out to me a simple typo. 感谢所有回答,我的问题变成了一个简单的错字。 Sorry to waste your time with such a rookie mistake 很抱歉浪费这样的菜鸟错误

  • check value of $_FILES["file"]["size"] first by echoing echo $_FILES["file"]["size"]; 首先通过回显echo $ _FILES [“ file”] [“ size”]来检查$ _FILES [“ file”] [“ size”]的值;
  • check values of $_FILES by print_r($_FILES); 通过print_r($ _ FILES)检查$ _FILES的值; Depending on the values u can check for conditions 根据值,您可以检查条件

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

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