いつものように、ここは私がたくさん学んだ場所です。そして、私は今、学ぶべき新しいことを持っています:
私はhtmlフォームを持っています:
<tr><td width="16%">File attachment</td><td width="2%">:</td><td><input type="file" name="fileatt" /></td></tr>
およびmail.php:
$attachfile=$_POST["fileatt"];
電子メールを送信するための正しいswiftmailerコード。
私はグーグルで検索し、ウェブサイトに保存されているファイルで添付ファイルを送信する方法の例をたくさん見つけましたが、その場でやりたいと思います。したがって、ボタンを送信すると、ファイルをアップロードするのではなく、人々に送信されます。
// Create the Transport
$transport = Swift_SmtpTransport::newInstance('mail.server.co.uk', 25)
->setUsername('user')
->setPassword('pass')
;
// Create the Mailer using your created Transport
$mailer = Swift_Mailer::newInstance($transport);
// Create a message
$message = Swift_Message::newInstance($subject)
->setFrom(array('emai@emai.com' => 'name'))
->setBody($html, 'text/html')
;
// Add alternative parts with addPart()
$message->addPart(strip_tags($html), 'text/plain');
// Send the message
$result = $mailer->send($message);
誰かがその場でファイルをアップロードする方法を教えてもらえますか?前もって感謝します!!!