fuji Posted May 6, 2009 Share Posted May 6, 2009 Bonjour j ai un petit probleme je suis en train de modifier le formulaire de contact mais je me heurte à un soucis, comment joindre un fichier ? j ai bien ajouter dans le tpl : {l s='file'} <input type="file" name="file"> Puis dans le .php if (Mail::Send(intval($cookie->id_lang), 'contact', 'Message from contact form', array('{email}' => $_POST['from'],'{message}' => stripslashes($message),'{file}' => stripslashes($file)), $contact->email)) dans le fichier mail/contact.html je ne vois pas ce que je dois faire par contre pour gerer l upload dans l envoi de mailMerci d avance Link to comment Share on other sites More sharing options...
nautilebleu Posted May 26, 2009 Share Posted May 26, 2009 Si tu veux envoyer le fichier en PJ, tu peux utiliser le code suivant: // /web/contact-form.php (~ ligne 35) if (Mail::Send(intval($cookie->id_lang), 'contact', 'Message from contact form', array('{email}' => $_POST['from'], '{message}' => stripslashes($message)), $contact->email)) // devient if (count($_FILES)> 0) { $temp_name = explode('.', $_FILES['file']['name']) ; $ext = $temp_name[count($temp_name)-1] ; $name = sprintf('%s.%s', mktime(), $ext) ; $path = sprintf('%s%supload%s%s', dirname(__FILE__), DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR, $name) ; if (move_uploaded_file($_FILES['file']['tmp_name'], $path)) { $attachment = array( 'content' => file_get_contents($path), 'mime' => $_FILES['file']['type'], 'name' => $name ); } else { $attachment = NULL ; } } if (Mail::Send(intval($cookie->id_lang), // $id_lang 'contact', // $template 'Message from contact form', // $subject array('{email}' => $_POST['from'], //templateVars '{message}' => stripslashes($message) ), $contact->email, // $to NULL, // $toName NULL, // $from NULL, // $fromName $attachment )) { $smarty->assign('confirmation', 1); } else { $errors[] = Tools::displayError('an error occurred while sending message'); } if (count($_FILES)> 0) { unlink($path); } Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now