upload send multiple files

Upload multiple files, insert into database, send email with multiple attachments

WordPress Custom code to upload files and save data into the database after successful upload send all files as attachments in an email to user.

Do you want professional help? We’ll repair it for you! Get assist Contact here!

if(isset($_POST['status'])){

    $uploaddir = '/home/public_html/wp-content/uploads/order-doc-folder/';
    
    foreach($_FILES['docat'] as $key => $doc){
        
      if($_FILES['docat']['name'][$key] != ''){
            
            $temp = explode(".", $_FILES['docat']['name'][$key]);
            $newfilename = $_REQUEST['order_id'].'-'.round(microtime(true)) . '-'.$temp[0].'.' . end($temp);
            
            $uploadfile = $uploaddir . basename($newfilename);
            
            if( move_uploaded_file($_FILES['docat']['tmp_name'][$key], $uploadfile)){
                $filename[] = $newfilename;
                $filenamed[] = $uploadfile;
            }
        }
    }
  
$wpdb->query('update submit_order set status="'.$_POST['status'].'" where id = '.$_REQUEST['order_id']);
$wpdb->query("insert into order_status_history set status='".$_POST['status']."', comment='".$_POST['comment']."', filelist = '".serialize($filename)."', product_id = ".$_REQUEST['order_id']);
    
    
    $subject = 'Your Order status update';
    $message = '

Dear Customer,
Your order no: '.$result->u_id.' current status is '.$_POST['status'].'
'.$_POST['comment'].'
Thanks
'; $senderName = "Talk For WEB"; $senderEmail = "info@talkforweb.com.au"; $from = $senderName." <".$senderEmail.">"; $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 attachment if(!empty($filenamed)){ for($i=0;$iemail, $subject, $message, $headers, $returnpath); $updateo = true; // Return true, if email sent, otherwise return false if($mail){ return true; }else{ return false; }

Upload multiple files, insert into database, send email with multiple attachments

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *