Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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