Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3114
  • Last Modified:

PHPMailer()

I'm using PHPMailer() to send an automated email to my client whenever someone applies to join his association online, and it's working fine.  Potential clients are also supposed to upload a small portfolio to our server, which is also working fine.

My question is how can I include the file they just uploaded as an attachment in the automated email?  Here's the relevant code - I'm kind of stuck at this point.

      $uploaddir = "../uploads/";
      $uploadfile = $uploaddir . $_FILES['mApp_file']['name'];
      
      if (move_uploaded_file($_FILES['mApp_file']['tmp_name'], $uploadfile)) {}
      
      $mail->AddAttachment("http://www.adianl.ca/uploads/" . $_FILES['mApp_file']['name']);  // optional name
      
      $mail->Send();

The email is also obviously HTML formatted.  I'm not receiving any errors when I try to include the attachment, it's just not attaching anything...is it possible to attach a file straight from the user's computer, rather than uploading it to the server, then downloading it again for the email?
0
jpve
Asked:
jpve
1 Solution
 
frugleCommented:
If you use the FILE input control, the file should be available in the $_FILES array

http://uk.php.net/features.file-upload
The Variables defined for uploaded files differs depending on the PHP version and configuration. The autoglobal $_FILES exists as of PHP 4.1.0 The $HTTP_POST_FILES array has existed since PHP 4.0.0. These arrays will contain all your uploaded file information. Using $_FILES is preferred. If the PHP directive register_globals is on, related variable names will also exist. register_globals defaults to off as of PHP 4.2.0.

You do need to add enctype="multipart/form-data" to your FORM tag though...  is the upload file coming through?

When you attach - you're using the original name for it. Have you tried attaching $uploadfile ?

Let me know!

Mike
0
 
jpveAuthor Commented:
Using $uploadfile worked - thanks a million.
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now