Jump to content

[SOLVED] foreach help


dennismonsewicz

Recommended Posts

I have the following error from my code:

 

Warning: Invalid argument supplied for foreach() in csv_upload.php on line 10

 

Here is my code:

 

foreach($_FILES['file']['name'] as $n => $name) {
	if(!empty($name)) {
		$target_path = "path_to_upload_folder/" . $name;
		if(move_uploaded_file($_FILES['file']['tmp_name'][$n], $target_path)) {
			echo 'files loaded';
			}
		}
	}

 

form code:

 

echo '<form action="csv_upload.php?action=upload&osCAdminID=' . $session_id . '" method="post">';
			echo '<label for="file1">File 1</label> <input type="file" name="file[]" />';
			echo '<br /><br />';
			echo '<label for="file2">File 2</label> <input type="file" name="file[]" />';
			echo '<br /><br />';
			echo '<input type="submit" value="Submit Information" />';
		echo '</form>';

Link to comment
https://forums.phpfreaks.com/topic/130763-solved-foreach-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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