Illegal offset type
arrays, file-upload, php
Solution
You are passing an array, not a string/integer index to your `checkFile` function.
To fix this, make one of the following to changes:
Change checkfile so that it uses the array passed in to do the checking, thusly:
if( in_array($file['type'], $type) )
OR change the code that calls this function so that it passes the name of the file to use as an index rather than the file array, thusly:
if( checkFile('Picture', array("image/jpeg") ) == true )
Either change will work.
Problem
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?