kanoy83 Posted October 28, 2013 Share Posted October 28, 2013 simple question what is the meaning and purpose of this: if($_FILES) thanks, cheers! Quote Link to comment Share on other sites More sharing options...
Ch0cu3r Posted October 28, 2013 Share Posted October 28, 2013 (edited) It is checking to see if $_FILES super global array contains something. When files are uploaded from a form this superglobal array will contain information about the uploaded file(s). If no files are uploaded it'll be empty. Read the following to see what possible information is contained within this variable http://www.php.net/manual/en/features.file-upload.post-method.php Edited October 28, 2013 by Ch0cu3r Quote Link to comment Share on other sites More sharing options...
ignace Posted October 28, 2013 Share Posted October 28, 2013 (edited) http://us2.php.net/manual/en/reserved.variables.files.php http://us2.php.net/manual/en/control-structures.if.php You are welcome! Edited October 28, 2013 by ignace Quote Link to comment Share on other sites More sharing options...
vinny42 Posted October 29, 2013 Share Posted October 29, 2013 What is if ($_FILES) What it is, is "wrong" :-) It tries to see if files were uploaded but it doesn't actually do that, it checks if the $_FILES array can be transformed to a boolean and if *that* results in "true". This means that it wil return true whenever $_FILES contains somthing other than NULL or an empty array. It does *not* mean itwill return true only if files were actually uploaded. So if your script contains a bug that assigns a value to $_FILES, perhaps something like "if ($_FILES['foo'[]='bar')" where you meanty to do "if ($_FILES['foo'[]=='bar')" then this statement will happily claim that files were uploaded. So, always check for the actual data you need, never assume that PHP is magic and that converting anything to boolean will just make it work. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.