Page 1 of 1

Invalid argument supplied for foreach()

Posted: Mon Nov 06, 2006 12:06 pm
by $var
Hi, I'm using the following code in a multiple file upload,
it used to work, but i moved servers and now i get an error in the foreach area:

Warning: Invalid argument supplied for foreach()

Code: Select all

//START IMAGE UPLOAD
		$path = $_SERVER['DOCUMENT_ROOT']."/it/files/".$issueID;
		if(!is_dir($path)) { //if $path isn't a dir
		mkdir($path, 0755); //create it
		}
		foreach( $HTTP_POST_FILES as $aFile )
		{
				copy ($aFile['tmp_name'], $path."/".$aFile['name']) 
					or die (""); 
		}
Any ideas? The form is multi-part, in case that was a thought.

Posted: Mon Nov 06, 2006 12:12 pm
by volka

Code: Select all

<?php
echo 'version: ', phpversion(), "<br />\n";
echo 'register_long_arrays: ', var_dump(ini_get('register_long_arrays')), "<br />\n";
?>
what does that print?

Posted: Mon Nov 06, 2006 12:23 pm
by $var

Code: Select all

version: 5.1.2
register_long_arrays: string(0) ""

Posted: Mon Nov 06, 2006 12:28 pm
by volka
You have to use $_FILES instead.
see http://www.php.net/reserved.variables#r ... bles.files

Posted: Mon Nov 06, 2006 1:03 pm
by $var
you're amazing, thank you.