Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7864405
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T23:46:48+00:00 2026-06-02T23:46:48+00:00

I am sending a single attachment with an email message using the following code.

  • 0

I am sending a single attachment with an email message using the following code. I use the phpmailer class: I know it’s a very simple and easy thing, but it is not working.

This is my php call;

$mail->AddAttachment($_FILES['attach']['name']);

This is my html;

<form id="Form" name="Form" method="POST" action="<?php $PHP_SELF ?>"  enctype="multipart/form-data">
<input id="attach" name="attach" type="file" />

I am sending an email with it too. The email is sent, but the attachment is not. Can anyone help me?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T23:46:49+00:00Added an answer on June 2, 2026 at 11:46 pm

    Encapsulate your code with error checking code so you know whether or not it worked:

    if (!$mail->AddAttachment($filepath, $_FILES['attach']['name']) {
      echo "Error attaching file at $filepath. Dumping variables to output.";
      var_dump($_FILES['attach']);
    }
    

    Note you can’t simply pass the name of the file to the the AddAttachment method; the first parameter is expected to be a path, as per the PHPMailer API. You have to figure out what that path is, and then also include the name of the file.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When sending email using the SMTPClient class in ASP.NET C#, how can I add
I am sending sms to recipients using following code private void button1_Click(object sender, EventArgs
For sending mass emails I use single instance of MailMessage class and filling it
Sending a message from the Unix command line using mail TO_ADDR results in an
sending mail along with embedded image using asp.net I have already used following but
Sending Email in Android using JavaMail API without using the default/built-in app I'm trying
I want to use php mailer for sending multiple attachment in mail. But the
sample1.php?q=+str This code is for sending single parameter i need to send multiple variables
Consider the following code sending an HTTP 201 Created response to the client: String
I have been using CDOSys object for email sending in Classic ASP and it's

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.