Illegal offset type

Posted by BFTrick on Stack Overflow See other posts from Stack Overflow or by BFTrick
Published on 2010-02-02T23:07:07Z Indexed on 2010/05/27 9:41 UTC
Read the original article Hit count: 237

Filed under:
|
|

Hello,

I am having trouble uploading a file through php. I check the file type at the beginning of the process and I get an error.

This is the error I am getting:

Warning: Illegal offset type in /balblabla/DBfunctions.inc.php on line 183

This is the printed out $_FILES var

Array ( [Picture] => Array ( [name] => JPG.jpg [type] => image/jpeg [tmp_name] => /tmp/phpHlrNY8 [error] => 0 [size] => 192221 ) )

Here is the segment of code I am using that is giving me issues:

function checkFile($file, $type)
{
    if( in_array($_FILES[$file]['type'], $type) ){    //   <---  LINE 183
        return true;
    }//if
    return false;
} // end checkFile()

This is the line of code that calls the function

if( checkFile( $_FILES['Picture'], array("image/jpeg") ) == true ){
//do stuff
}// end if

I have used this piece of code on dozens of websites on my own server so i am guessing that this is some different configuration option. How can i modify my code so that it works on this different server?

© Stack Overflow or respective owner

Related posts about php

Related posts about arrays