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

  • Home
  • SEARCH
  • 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 9163507
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T14:27:50+00:00 2026-06-17T14:27:50+00:00

When I use this form I made, it sends the files perfectly, except… it

  • 0

When I use this form I made, it sends the files perfectly, except… it leaves off the extension. I knew what extension I sent so I was able to see that the file wasn’t corrupted, but my customer won’t know what extension they’re getting (there are like 5 possibilities) and it would be unprofessional. How can I make it so this sends the customer the file with the correct extension. The correct name would be good also, but isn’t mandatory.

HTML:

</p>
<title>The Legend Maker - submit a story (test server)</title>
<link href="/CSS/CSS.css" rel="stylesheet" type="text/css">

<div align="center">
  <p><span class="linkText"><a href="/index.html">Home</a> <a href="/contact-us.php">Contact Us</a> <a href="/payments.html">Payments</a></span> </p>
  <p>&nbsp;</p>
  <h2 class="headingText">&nbsp;</h2>
  <h2 class="headingText">&nbsp;</h2>
  <h2 class="headingText">&nbsp;</h2>
  <h2 class="headingText">(for testing purposes)</h2>
  <h2 class="headingText">Submit a story test server</h2>
</div>
<form method="post" action="scripts/email.php" enctype="multipart/form-data">
<table width="476" height="468" border="0" cellpadding="0" cellspacing="2">
<tr>
<td width="23%" height="25" class="bodytext"><p align="center">Your Name:</p></td>
<td width="77%"><input name="name" type="text" id="name" size="32"></td>
</tr>
<tr>
<td height="25" class="bodytext"><p align="center">Email Address:</p></td>
<td><input name="email" type="text" id="email" value="you@example.com" size="32"></td>
</tr>
<tr>
<td height="44" class="bodytext"><p align="center">Recipient's Gender:</p></td>
<td><label>
  <select name="gender" id="gender">
    <option value="male" selected="selected">Male</option>
    <option value="female">Female</option>
    <option value="other">Other</option>
        </select>
</label></td>
</tr>
<tr>
<td height="44" class="bodytext"><p align="center">Recipient's Name:</p>  </td>
<td align="left" valign="top"><input name="recipientname" type="text" id="recipientname" value="ex: Jonny" size="32" /></td>
</tr>
<tr>
  <td height="44" class="bodytext"><p align="center">Recipient's Interests or Hobbies:</p></td>
  <td align="left" valign="top"><textarea name="hobbies" cols="50" rows="6" id="hobbies">ex: horseback riding, biking...</textarea></td>
</tr>
<tr>
  <td class="bodytext"><p align="center">Recipient's Age:</p></td>
  <td align="left" valign="top"><input name="age" type="text" id="age" size="5" maxlength="3" /></td>
</tr>
<tr>
  <td class="bodytext"><p align="center">Other Important Information:</p></td>
  <td align="left" valign="top"><textarea name="otherinfo" cols="50" rows="7" id="otherinfo">ex: other things the recipient may enjoy or their favorite superhero
Please specify information you are giving us also:
don't do this: superman
submit it like this: favorite superhero: superman</textarea></td>
</tr>
<tr>
  <td class="bodytext"><p align="center">Images You Would Like To Include In Story:</p></td>
  <td align="left" valign="top"><label>
    <br />
    <input type="file" name="file" id="file" />
  </label></td>
</tr>
<tr>
  <td class="bodytext"><p align="center">&nbsp;</p></td>
  <td align="left" valign="top"><input type="submit" name="Submit" value="Send" /></td>
</tr>
</table>
</form> 

PHP:

 <?php
    require_once '../PHPMailer_5.2.2/class.phpmailer.php';

    $name = $_POST['name'] ;
    $email = $_POST['email'] ;
    $gender = $_POST['gender'] ;
    $recipientname = $_POST['recipientname'] ;
    $hobbies = $_POST['hobbies'] ;
    $age = $_POST['age'] ;
    $otherinfo = $_POST['otherinfo'] ;
    $file = $_POST['file'] ;
    $body = "Name: $name
    Email: $email
    Gender: $gender
    Recipient's name: $recipientname
    Hobbies: $hobbies
    Age: $age
    Other Information: $otherinfo";

    $mail = new PHPMailer(true); //defaults to using php "mail()"; the true param means it will throw exceptions on errors, which we need to catch

    try {
      $mail->AddAddress('***erna@yahoo.com', 'Michael ***');
      $mail->SetFrom($email, $name);
      $mail->AddReplyTo($email, $name);
      $mail->Subject = "Message From Legendmaker Customer: $name";
      $mail->Body = $body;
      $mail->AddAttachment($_FILES['file']['tmp_name']);      // attachment
      $mail->Send();
      echo "Story Request Sent Successfully</p>\n";
    } catch (phpmailerException $e) {
      echo $e->errorMessage(); //Pretty error messages from PHPMailer
    } catch (Exception $e) {
      echo $e->getMessage(); //Boring error messages from anything else!
    }
    ?>
  • 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-17T14:27:51+00:00Added an answer on June 17, 2026 at 2:27 pm

    I checked the source for PHPMailer and this is what I found for the function signature.

    AddAttachment($path, $name = '', $encoding = 'base64', $type = 'application/octet-stream') 
    

    To solve your problem all you should have to do is this:

    $mail->AddAttachment($_FILES['file']['tmp_name'], $_FILES['file']['name']);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I frequently find myself creating classes which use this form (A): abstract class Animal
I'd like to use MySQL in this form: SELECT 1 AS one, one*2 AS
I have my form in a table and I use this code to add
Is it possible to use jqueries each loop in this form to dissolve hyperlinks?
I have this easy little form in my JavaFX application. I want to use
I've been looking around to see if you can use footer like this: <form>
Is this possible to use Ajax.Beginform with update target inside of ajax form. like
I am trying to use an HTML form and javascript (i mention this, because
I am using this tutorial to create a login form http://www.ryancoughlin.com/2008/11/04/use-jquery-to-submit-form/ It authenticates against
I have an C# form application that use an access database. This application works

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.