Solved

PHPMailer()

Posted on 2004-08-31
2
3,096 Views
Last Modified: 2013-12-12
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
Comment
Question by:jpve
2 Comments
 
LVL 10

Accepted Solution

by:
frugle earned 50 total points
ID: 11946979
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
 

Author Comment

by:jpve
ID: 11952244
Using $uploadfile worked - thanks a million.
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now