Ecommerce Shopify WordPress Discussion

attachment input php wp mail

I'm developing an order form on a WordPress website. The form is created in HTML, and I use PHP to process the data, generate the HTML email, and send it to an email using WP MAIL SMTP. The order process works correctly for my project, but I'm having difficulty adding a file input. The input I'm trying to use is this <input type="file" id="requerimentoFileId" name="anexoEmail" accept=".pdf, .jpg, .jpeg, .png">. How do I go about sending the file as an attachment in PHP? <?php include_once($_SERVER['DOCUMENT_ROOT'].'/site/wp-load.php'); if ($_SERVER["REQUEST_METHOD"] == "POST") { // Coleta dados do formulário $nomeRequerente = $_POST["nomeRequerente"]; $emailRequerente = $_POST["emailRequerente"]; $telefoneRequerente = $_POST["telefoneRequerente"]; $nomeRegistrado = $_POST["nomeRegistrado"]; $nomePaiRegistrado = $_POST["nomePaiRegistrado"]; $nomeMaeRegistrado = $_POST["nomeMaeRegistrado"]; $dataNascRegistrado = $_POST["dataNascRegistrado"]; $livroRegistrado = $_POST["livroRegistrado"]; $folhaLivroRegistrado = $_POST["folhaLivroRegistrado"]; $termoLivroRegistrado = $_POST["termoLivroRegistrado"]; $tipoCertidao = $_POST["tipoCertidao"]; $mensagem = $_POST["mensagem"]; $entregaOpcao = $_POST["entrega"]; $destinatario = ""; $assunto = "Pedido de Certidão de Nascimento"; // Template HTML $template = <<<EOD <h2 style="color: #4d71e6; text-transform: uppercase; text-align: center; font-family: Arial, 'Helvetica Neue', Helvetica, sans-serif; font-size: 1.5rem; font-style: normal; font-weight: 500; line-height: normal; margin: 22px 0 32px;">Pedido Certidão de Nascimento</h2> EOD; $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/html; charset=UTF-8\r\n"; // Enviar e-mail usando wp_mail if (wp_mail($destinatario, $assunto, $template, $headers)) { echo 'success'; } else { echo 'error'; } } else { echo 'error'; } ?>
TurboCommerce make the better internet purchasing globaly

Turbo Multi-language Translator

Make the better internet purchasing globaly

Turbosify SEO Speed Booster

5.0 (7) Free plan available
Get better conversions by improving store loading speed Installed

Turbo Multi-language Chat - AI Customer service in one hand

TurboCommerce make the better internet purchasing globaly
Our products

The help you need, when you need it

App by Turbo Engine

3 apps • 5.0 average rating

Turbosify Speed Booster

5.0 (7)
Get better conversions by optimizing shopify store Google page speed Installed

Turbosify Translator for Wordpress Woocommerce

5.0 (74) Free Wordpress Woocommerce Plugin
Translate your wordpress website to multiple language within 1 click, no configuration needed, no No technical required

Grow your business here

Whether you want to sell products down the street or around the world, we have all the tools you need.