Page 1 of 1

Array not working

Posted: Sat May 29, 2010 8:07 am
by c_pattle
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

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>
And this is my php code

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);

Re: Array not working

Posted: Sat May 29, 2010 10:06 am
by AbraCadaver
The $_FILES array is not structured how you think it is. Do this to see:

Code: Select all

echo "<pre>"; print_r($_FILES); echo "</pre>";