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 |