I have collected two great codes the I am running together on our site
This is the HTML part of the code and where I be leave the input areas would go.
[php]
Multiple Images Upload Using jQuery, Ajax and PHP by CodexWorld<div class="gallery" id="images_preview"></div>
[php][php]<?php
if($_POST[‘image_form_submit’] == 1)
{
$images_arr = array();
foreach($_FILES[‘images’][‘name’] as $key=>$val){
$image_name = $_FILES[‘images’][‘name’][$key];
$tmp_name = $_FILES[‘images’][‘tmp_name’][$key];
$size = $_FILES[‘images’][‘size’][$key];
$type = $_FILES[‘images’][‘type’][$key];
$error = $_FILES[‘images’][‘error’][$key];
$target_dir = "uploads/";
$target_file = $target_dir.$_FILES['images']['name'][$key];
if(move_uploaded_file($_FILES['images']['tmp_name'][$key],$target_file)){
$images_arr[] = $target_file;
}
//display images without stored
/*$extra_info = getimagesize($_FILES['images']['tmp_name'][$key]);
$images_arr[] = "data:" . $extra_info["mime"] . ";base64," . base64_encode(file_get_contents($_FILES['images']['tmp_name'][$key]));*/
}
//Generate images view
if(!empty($images_arr)){ $count=0;
foreach($images_arr as $image_src){ $count++?>
<ul class="reorder_ul reorder-photos-list">
<li id="image_li_<?php echo $count; ?>" class="ui-sortable-handle">
<a href="javascript:void(0);" style="float:none;" class="image_link"><img src="<?php echo $image_src; ?>" alt=""></a>
</li>
</ul>
<?php }
}
}
?>[/php]
After this point it becomes a mail sent the sends the same two files each time (could live with out file send here)
[php]<?php
function multi_attach_mail($to, $subject, $message, $senderMail, $senderName, $files){
$from = $senderName." <".$senderMail.">";
$headers = "From: $from";
// boundary
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
// headers for attachment
$headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\"";
// multipart boundary
$message = "--{$mime_boundary}\n" . "Content-Type: text/html; charset=\"UTF-8\"\n" .
"Content-Transfer-Encoding: 7bit\n\n" . $message . "\n\n";
// preparing attachments
if(count($files) > 0){
for($i=0;$i<count($files);$i++){
if(is_file($files[$i])){
$message .= "--{$mime_boundary}\n";
$fp = @fopen($files[$i],"rb");
$data = @fread($fp,filesize($files[$i]));
@fclose($fp);
$data = chunk_split(base64_encode($data));
$message .= "Content-Type: application/octet-stream; name=\"".basename($files[$i])."\"\n" .
"Content-Description: ".basename($files[$i])."\n" .
"Content-Disposition: attachment;\n" . " filename=\"".basename($files[$i])."\"; size=".filesize($files[$i]).";\n" .
"Content-Transfer-Encoding: base64\n\n" . $data . "\n\n";
}
}
}
$message .= "--{$mime_boundary}--";
$returnpath = "-f" . $senderMail;
//send email
$mail = @mail($to, $subject, $message, $headers, $returnpath);
//function return true, if email sent, otherwise return fasle
if($mail){ return TRUE; } else { return FALSE; }
}
//email variables
$to = ‘[email protected]’;
$from = ‘[email protected]’;
$from_name = ‘CodexWorld’;
//attachment files path array
$files = array(‘you-have.jpg’,‘files.jpg’);
$subject = ‘PHP Email with multiple attachments by CodexWorld’;
$html_content = ‘
PHP Email with multiple attachments by CodexWorld
Total Attachments : ‘.count($files).’ attachments
’;//call multi_attach_mail() function and pass the required arguments
$send_email = multi_attach_mail($to,$subject,$html_content,$from,$from_name,$files);
//print message after email sent
echo $send_email?"
Mail Sent
":"Mail not SEND
";?>[/php]
[/php]
I am hoping that it can be made to send me Name, Email Address, and File Info.