Only the last selected attachment is sent, in phpmailer

I m sending an Email with multiple attachments through phpmailer. The loop i used to send multiple attachments is The Message going with attachment, only contain the last choosen file, and the first two or one files are not sent. Is there a problem with Loop. Please :

[php] foreach($_FILES as $key => $file){
$target_path = “uploads/”;
$target_path = $target_path .basename($file[‘name’]);

if(move_uploaded_file($file[‘tmp_name’], $target_path)) {
echo “the file “.basename($file[‘name’]).” has been uploaded”;
}else {
echo “there was an error”;
}
mail->AddAttachment($target_path);
}

 <form id=
   "mail" name="mail" method="POST" action="<?php $PHP_SELF ?>" 
enctype="multipart/form-data">
 <input type="file" name="uploaded" multiple="" />
<input name="Submit1" type="submit" value="Submit"  />
</form>[/php]

Because you’re not actually doing anything with the loop, its just there for looks. plus $target_path isn’t the actual file, its not even really a file.

Without seeing the the entire upload script, it doesn’t look like its processing any more than 1 file. That’s all its going to send out since that is what’s being uploaded.

Sponsor our Newsletter | Privacy Policy | Terms of Service