lkenn Posted February 12, 2013 Share Posted February 12, 2013 I am new to this so this is probably a stupid question but, how do I access [userfile1] and [userfile2] in the following code to write a foreach statement that runs on each of those arrays in $_FILES. For context: these files populate $_FILES via an html form with two browse buttons - one for each file to upload - and one submit button. The following output was produced with <pre><?php print_r($_FILES); ?> </pre> . Any help is appreciated. Thanks. Array ( [userfile1] => Array ( [name] => Hay-Bales-LeoKenney.jpg [type] => image/jpeg [tmp_name] => C:\wamp\tmp\php441.tmp [error] => 0 => 356369 ) [userfile2] => Array ( [name] => LK-Holding on.jpg [type] => image/jpeg [tmp_name] => C:\wamp\tmp\php442.tm [error] => 0 => 312401 ) ) Quote Link to comment https://forums.phpfreaks.com/topic/274412-accessing-multiple-arrays-in-_files/ Share on other sites More sharing options...
Barand Posted February 12, 2013 Share Posted February 12, 2013 read http://php.net/manual/en/features.file-upload.multiple.php Quote Link to comment https://forums.phpfreaks.com/topic/274412-accessing-multiple-arrays-in-_files/#findComment-1412059 Share on other sites More sharing options...
lkenn Posted February 13, 2013 Author Share Posted February 13, 2013 Thanks for the advice. I read the resource and everything I tried just broke the code that already worked. The problem I am having is that I still can't figure out how to loop through the arrays that are in $_FILES Quote Link to comment https://forums.phpfreaks.com/topic/274412-accessing-multiple-arrays-in-_files/#findComment-1412120 Share on other sites More sharing options...
Barand Posted February 13, 2013 Share Posted February 13, 2013 (edited) you loop through the arrays by following the example in the link I gave, giving the file inputs the name="userfile[]". You have given them different names so no looping. Edited February 13, 2013 by Barand Quote Link to comment https://forums.phpfreaks.com/topic/274412-accessing-multiple-arrays-in-_files/#findComment-1412121 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.