Jump to content

What is if($_FILES)


kanoy83

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/283385-what-is-if_files/#findComment-1455918
Share on other sites

 


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.

Link to comment
https://forums.phpfreaks.com/topic/283385-what-is-if_files/#findComment-1455994
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.