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

Edited by Ch0cu3r
Link to comment
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.