Load classes earlier

This commit is contained in:
Marcus Bointon 2020-10-29 15:33:52 +01:00
parent 9a85f499b2
commit 3dffb3e4ee
No known key found for this signature in database
GPG Key ID: DE31CD6EB646AA24
2 changed files with 4 additions and 2 deletions

View File

@ -7,6 +7,8 @@
//Import the PHPMailer class into the global namespace //Import the PHPMailer class into the global namespace
use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\PHPMailer;
require '../vendor/autoload.php';
$msg = ''; $msg = '';
if (array_key_exists('userfile', $_FILES)) { if (array_key_exists('userfile', $_FILES)) {
// First handle the upload // First handle the upload
@ -20,7 +22,6 @@ if (array_key_exists('userfile', $_FILES)) {
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) { if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
// Upload handled successfully // Upload handled successfully
// Now create a message // Now create a message
require '../vendor/autoload.php';
$mail = new PHPMailer(); $mail = new PHPMailer();
$mail->setFrom('from@example.com', 'First Last'); $mail->setFrom('from@example.com', 'First Last');
$mail->addAddress('whoto@example.com', 'John Doe'); $mail->addAddress('whoto@example.com', 'John Doe');

View File

@ -7,9 +7,10 @@
//Import the PHPMailer class into the global namespace //Import the PHPMailer class into the global namespace
use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\PHPMailer;
require '../vendor/autoload.php';
$msg = ''; $msg = '';
if (array_key_exists('userfile', $_FILES)) { if (array_key_exists('userfile', $_FILES)) {
require '../vendor/autoload.php';
// Create a message // Create a message
$mail = new PHPMailer(); $mail = new PHPMailer();
$mail->setFrom('from@example.com', 'First Last'); $mail->setFrom('from@example.com', 'First Last');