This should help with uploading more than one file
HTML Form (look at the bold parts)
<form enctype="multipart/form-data" name="send" method="post" action="<?=$_SERVER['PHP_SELF']?>">
<input type="hidden" name="action" value="send" />
<input type="hidden" name="MAX_FILE_SIZE" value="10000000" />
<p> From Email:
<input name="from_email" size="50" />
<br />
Message:
<textarea name="body" rows="10" cols="50"></textarea>
[B] <div id="files"><br />
Attachment:
<input type="file" name="attachment[]" size="50" />
<br /></div>[/B]
<br />
[B] <input type ="button" value='Attach Another File" onclick='addnew("files")' />[/B]
<br />
<br />
<input type="submit" value="Send Email" />
</p>
</form>
Javascript side of adding additional upload forms. PUT THIS ABOVE HTML FORM.
<script type="text/javascript">
var counter = 1;
var upload_limit = 4;
function addnew(divName){
if(counter==upload_limit){
alert('Image Limit has been reached, upload the current set of images then come back to upload the rest');
}
else {
var new_upload = document.createElement('div');
new_upload.innerHTML = "<br />
Attachment:
<input type="file" name="attachment[]" size="50" />
<br />";
document.getElementById(divName).appendChild(new_upload);
counter++;
}
}
</script>
PHP side of things...
//WHEN YOU CHECK IF FILE UPLOADED OR NOT
foreach ($_FILES['attachment']['name'] as $x=>value)
{
$attachment[$x] = $_FILES['attachment']['tmp_name'][$x];
$attachment_name[$x] = $_FILES['attachment']['name'][$x];
if (is_uploaded_file($attachment[$x])) { //Do we have a file uploaded?
$fp = fopen($attachment[$x], "rb"); //Open it
$data[$x] = fread($fp, filesize($attachment[$x])); //Read it
$data[$x] = chunk_split(base64_encode($data)); //Chunk it up and encode it as base64 so it can emailed
fclose($fp);
}
}
//Then you have to insert them all, when doing this again use the foreach statement, i think it should work... get back to me :)