Solved

PHPMailer()

Posted on 2004-08-31
2
3,112 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

Independent Software Vendors: 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

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

628 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