Salve,
devo inviare un allegato per email con un form in html
<div class="form-group">
<label>Allegato</label>
<input type="file" name="allegato">
</div>
In php come lo implemento per scaricare l'allegato una volta che arriva l'email?
<?php
session_start();
require_once 'smarty/libs/Smarty.class.php';
require_once 'setup/config.php';
$smarty = new Smarty;
$smarty->setCompileDir('smarty/application/templates_c');
$smarty->setCacheDir('smarty/application/cache');
$to = "[email protected]";
$body .= "Messaggio: " . trim(stripslashes($_POST["messaggio"])) . "\n";
$body .= "Numero di Telefono: " . trim(stripslashes($_POST["tele"])) . "\n";
$body .= "Allegato: " . trim(stripslashes($_POST["allegato"])) . "\n";
$subject .= "Oggetto: " . trim(stripslashes($_POST["oggetto"])) . "\n";
$headers = "From: " . trim(stripslashes($_POST["email"])) . "\n";
// INVIO DELLA MAIL
if(@mail($to, $subject, $body, $headers) == true) { // SE L'INOLTRO È ANDATO A BUON FINE...
$smarty->assign('insertError', 'Email inviata');
} else {// ALTRIMENTI...
$smarty->assign('insertError', 'Email non inviata');
}
$smarty->display('smarty/application/templates/main_content/index.tpl');
devo inviare un allegato per email con un form in html
<div class="form-group">
<label>Allegato</label>
<input type="file" name="allegato">
</div>
In php come lo implemento per scaricare l'allegato una volta che arriva l'email?
<?php
session_start();
require_once 'smarty/libs/Smarty.class.php';
require_once 'setup/config.php';
$smarty = new Smarty;
$smarty->setCompileDir('smarty/application/templates_c');
$smarty->setCacheDir('smarty/application/cache');
$to = "[email protected]";
$body .= "Messaggio: " . trim(stripslashes($_POST["messaggio"])) . "\n";
$body .= "Numero di Telefono: " . trim(stripslashes($_POST["tele"])) . "\n";
$body .= "Allegato: " . trim(stripslashes($_POST["allegato"])) . "\n";
$subject .= "Oggetto: " . trim(stripslashes($_POST["oggetto"])) . "\n";
$headers = "From: " . trim(stripslashes($_POST["email"])) . "\n";
// INVIO DELLA MAIL
if(@mail($to, $subject, $body, $headers) == true) { // SE L'INOLTRO È ANDATO A BUON FINE...
$smarty->assign('insertError', 'Email inviata');
} else {// ALTRIMENTI...
$smarty->assign('insertError', 'Email non inviata');
}
$smarty->display('smarty/application/templates/main_content/index.tpl');