Solved

PHPMailer()

Posted on 2004-08-31
2
3,107 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses four methods for overlaying images in a container on a web page
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
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 create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

740 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