Jump to content

[SOLVED] foreach ($_FILES ...


drisate

Recommended Posts

I am trying to do a multiple file uploader ... every imput has the name userfile[]

 

	foreach ($_FILES['userfile'] as $fi){
if (is_uploaded_file($fi['tmp_name'])) {
	Attach($fi['tmp_name'],$fi['name']);
}
}

 

For some reason $fi['tmp_name'] returns null bot not $_FILES['userfile']['tmp_name'] ...

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

The array will be $_FILES['userfile']['tmp_name'][0], $_FILES['userfile']['tmp_name'][1]...

 

You need to do -

 

foreach($_FILES['userfile']['tmp_name'] as $key => $value){

}

 

You can use the $key inside of the loop to access the other elements -

 

$_FILES['userfile']['error'][$key]

$_FILES['userfile']['size'][$key]

$_FILES['userfile']['name'][$key]

 

 

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.