Array not working
Posted: Sat May 29, 2010 8:07 am
I'm trying to create a script to send multiple attachments with one email. I'm using an array to store the attachments and then trying to use a foreach loop to email them. However for some reason my array seems to be empy. This is my html
And this is my php code
Code: Select all
<form method="post" action="order_success2.php" enctype="multipart/form-data">
<ul>
<li><input type="file" name="att[]" size="26" /></li>
<li><input type="file" name="att[]" size="26" /></li>
<li><input type="submit" name="submit" value="Submit!" /></li>
</ul>
</form>
Code: Select all
foreach($_FILES['att'] as $key => $value){
$att_path = $value['tmp_name'];
$att_name = $value['name'];
$att_size = $value['size'];
$att_type = $value['type'];
$fp = fopen( $att_path, "rb");
$file = fread( $fp, $att_size );
fclose ($fp);