Solved

PHPMailer()

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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

Suggested Solutions

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
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.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.

734 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