I am uploading two images. They pass through this script and get moved to a new folder. I am trying to grab the names from these two images and insert them into a data base. As is I get this error.
Warning: Invalid argument supplied for foreach() in /test03.php on line 32
Is there no array in $filenm? Or is there something wrong with my foreach statement? Thanks.
$filenm isn’t an array, which is way foreach() throws an error. You could create an array out of it, but in this case you could also move the body of the 2nd foreach into the body of the 1st foreach, change variables where needed, and that should work as well
I tried your first example and it worked perfectly.
I did more var_dumps($filenm); after move_uploaded_file and get this: string(0) “”.
I think I figured out why. I have three image slots but have only been using two for testing. So the third image name is not there ( string(0) “”). When I test with all three images being uploaded, var_dumps out only the third image.
It is kind of strange to me that $filenm seems to loose the array when passing through move_uploaded_file and then magically stores an array in $filenames=$filnm;. Now $filenames has the array.
It is a little confusing. My PHP books don’t always help with these issues.
Thanks for your help. I still have a lot more to integrate into this script. I think my better understanding will help me.
Thanks Kalon and oddz. I will investigate your suggestions.
I just experimented with placing var_dump($filenm); at different locations and discovered that the array in $filenm empties or disappears after passing
Can you tell me why $filenm is not an array and show me how to create an array out of $filenm just so I can learn. Then maybe I try your second solution. Thanks for your help.