php - Illegal offset type -
I am having trouble uploading a file via php, I check the file type at the beginning of the process and I get an error.
This is what I am getting the error:
WARNING: Invalid offset type / balblabla
print it out $ $ _FILES <[Pic] => array ([Name] => JPG.jpg [type] => image / jpeg [tmp_name] => / tmp / phpHlrNY8 [error]
=> 0 [size] => 192221))
function checkFile ($ file, $ type) {if_array ($ _ files [ $ File] [I 'type'], $ type)) // {<& lt; --- LINE 183 returns true; } // if return is false; } // end checkFile ()
This is the line of code that the function calls
if (checkFile ($ _FILES ['picture'], The array ("image / JPEG")) == true) {/ // do stuff}} // end if
I have used this code on dozens of my own servers Due to websites, I guess it is a different configuration option. How can I modify my code so that it works on this separate server?
You are passing an array, string / integer on your checkFile
function Not index
To fix this, do one of the changes:
Change the checkfile so that it can be used to check the array passed, this Type:
if (in_array ($ file ['type'], $ type))
or change code that calls this function so that File name passes in the form of the name of a file instead of file name, as follows:
if (checkfile ('image', array ("image"
Comments
Post a Comment