Jump to content


Photo

Warning: Invalid argument supplied for foreach() in /home/...


  • Please log in to reply
1 reply to this topic

#1 paulgc34

paulgc34
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 04 July 2006 - 03:38 PM

I want my visitors to be able to upload multiple image files. the script I'm using is:

<form action="" method="post" enctype="multipart/form-data">

<input type="file" name="pictures[]" />
<input type="file" name="pictures[]" />
<input type="file" name="pictures[]" />
<input type="submit" value="Send" />
</p>
</form>
<?php
foreach ($_FILES["pictures"]["error"] as $key => $error) {
if ($error == UPLOAD_ERR_OK) {
$tmp_name = $_FILES["pictures"]["tmp_name"][$key];
$name = $_FILES["pictures"]["name"][$key];
move_uploaded_file($tmp_name, "data/$name");
}
}
?>

When I goto the form this error is displayed at the bottom:
Warning: Invalid argument supplied for foreach() in /home/... 
using this script the files do upload successfuly and after uploading the files just once the error then goes away.
what do I need to do to rid the error when you first goto the page?

#2 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 04 July 2006 - 03:58 PM

works for me

<form action="" method="post" enctype="multipart/form-data">

<input type="file" name="pictures[]" />
<input type="file" name="pictures[]" />
<input type="file" name="pictures[]" />
<input type="submit" value="Send" />
</p>
</form>
<?php
foreach ($_FILES["pictures"]["error"] as $key => $error) {
if ($error == UPLOAD_ERR_OK) {
$tmp_name = $_FILES["pictures"]["tmp_name"][$key];
$name = $_FILES["pictures"]["name"][$key];
move_uploaded_file($tmp_name, "data/$name");
}
}

?>
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users