Jump to content

array image post


Dorky

Recommended Posts

i cannot find how to break down an array from multiple image post into a usable array to use in a foreach loop?

 

results from a print_r of the $_POST['new_image']

 

Array ( [name] => Array ( [0] => d.png [1] => sky.jpg ) [type] => Array ( [0] => image/png [1] => image/jpeg ) [tmp_name] => Array ( [0] => /tmp/php6WChM0 [1] => /tmp/phpU1UV9g ) [error] => Array ( [0] => 0 [1] => 0 ) => Array ( [0] => 1028 [1] => 110116 ) ) Array ( [0] => d.png [1] => sky.jpg ) Array ( [0] => image/png [1] => image/jpeg ) Array ( [0] => /tmp/php6WChM0 [1] => /tmp/phpU1UV9g ) Array ( [0] => 0 [1] => 0 ) Array ( [0] => 1028 [1] => 110116 )

Link to comment
https://forums.phpfreaks.com/topic/179617-array-image-post/
Share on other sites

you could just use a for loop. im assuming you want to do some image upload kind of thing

for ($i = 0; $i < count($_POST['new_image']['name']); $i++){
//access each individual element like so
$name = $_POST['new_image']['name'][$i];
$size = $_POST['new_image']['size'][$i];
//do rest of stuff
}

Link to comment
https://forums.phpfreaks.com/topic/179617-array-image-post/#findComment-947862
Share on other sites

you could just use a for loop. im assuming you want to do some image upload kind of thing

for ($i = 0; $i < count($_POST['new_image']['name']); $i++){
//access each individual element like so
$name = $_POST['new_image']['name'][$i];
$size = $_POST['new_image']['size'][$i];
//do rest of stuff
}

DUDE YOU ARE  THE MAN!!!!!

 

for ($i = 0; $i < count($_FILES['new_image']); $i++){
$imagename = $_FILES['new_image']['name'][$i];
$tmp_name = $_FILES['new_image']['tmp_name'][$i];

how long did that take you. i missed an entire nights sleep for that.

Link to comment
https://forums.phpfreaks.com/topic/179617-array-image-post/#findComment-947886
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.