Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP Form works great, but leaves off file extension
    primarykey
    data
    text
    <p>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.</p> <p>HTML: </p> <pre><code>&lt;/p&gt; &lt;title&gt;The Legend Maker - submit a story (test server)&lt;/title&gt; &lt;link href="/CSS/CSS.css" rel="stylesheet" type="text/css"&gt; &lt;div align="center"&gt; &lt;p&gt;&lt;span class="linkText"&gt;&lt;a href="/index.html"&gt;Home&lt;/a&gt; &lt;a href="/contact-us.php"&gt;Contact Us&lt;/a&gt; &lt;a href="/payments.html"&gt;Payments&lt;/a&gt;&lt;/span&gt; &lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;h2 class="headingText"&gt;&amp;nbsp;&lt;/h2&gt; &lt;h2 class="headingText"&gt;&amp;nbsp;&lt;/h2&gt; &lt;h2 class="headingText"&gt;&amp;nbsp;&lt;/h2&gt; &lt;h2 class="headingText"&gt;(for testing purposes)&lt;/h2&gt; &lt;h2 class="headingText"&gt;Submit a story test server&lt;/h2&gt; &lt;/div&gt; &lt;form method="post" action="scripts/email.php" enctype="multipart/form-data"&gt; &lt;table width="476" height="468" border="0" cellpadding="0" cellspacing="2"&gt; &lt;tr&gt; &lt;td width="23%" height="25" class="bodytext"&gt;&lt;p align="center"&gt;Your Name:&lt;/p&gt;&lt;/td&gt; &lt;td width="77%"&gt;&lt;input name="name" type="text" id="name" size="32"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td height="25" class="bodytext"&gt;&lt;p align="center"&gt;Email Address:&lt;/p&gt;&lt;/td&gt; &lt;td&gt;&lt;input name="email" type="text" id="email" value="you@example.com" size="32"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td height="44" class="bodytext"&gt;&lt;p align="center"&gt;Recipient's Gender:&lt;/p&gt;&lt;/td&gt; &lt;td&gt;&lt;label&gt; &lt;select name="gender" id="gender"&gt; &lt;option value="male" selected="selected"&gt;Male&lt;/option&gt; &lt;option value="female"&gt;Female&lt;/option&gt; &lt;option value="other"&gt;Other&lt;/option&gt; &lt;/select&gt; &lt;/label&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td height="44" class="bodytext"&gt;&lt;p align="center"&gt;Recipient's Name:&lt;/p&gt; &lt;/td&gt; &lt;td align="left" valign="top"&gt;&lt;input name="recipientname" type="text" id="recipientname" value="ex: Jonny" size="32" /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td height="44" class="bodytext"&gt;&lt;p align="center"&gt;Recipient's Interests or Hobbies:&lt;/p&gt;&lt;/td&gt; &lt;td align="left" valign="top"&gt;&lt;textarea name="hobbies" cols="50" rows="6" id="hobbies"&gt;ex: horseback riding, biking...&lt;/textarea&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td class="bodytext"&gt;&lt;p align="center"&gt;Recipient's Age:&lt;/p&gt;&lt;/td&gt; &lt;td align="left" valign="top"&gt;&lt;input name="age" type="text" id="age" size="5" maxlength="3" /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td class="bodytext"&gt;&lt;p align="center"&gt;Other Important Information:&lt;/p&gt;&lt;/td&gt; &lt;td align="left" valign="top"&gt;&lt;textarea name="otherinfo" cols="50" rows="7" id="otherinfo"&gt;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&lt;/textarea&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td class="bodytext"&gt;&lt;p align="center"&gt;Images You Would Like To Include In Story:&lt;/p&gt;&lt;/td&gt; &lt;td align="left" valign="top"&gt;&lt;label&gt; &lt;br /&gt; &lt;input type="file" name="file" id="file" /&gt; &lt;/label&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td class="bodytext"&gt;&lt;p align="center"&gt;&amp;nbsp;&lt;/p&gt;&lt;/td&gt; &lt;td align="left" valign="top"&gt;&lt;input type="submit" name="Submit" value="Send" /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/form&gt; </code></pre> <p>PHP:</p> <pre><code> &lt;?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-&gt;AddAddress('***erna@yahoo.com', 'Michael ***'); $mail-&gt;SetFrom($email, $name); $mail-&gt;AddReplyTo($email, $name); $mail-&gt;Subject = "Message From Legendmaker Customer: $name"; $mail-&gt;Body = $body; $mail-&gt;AddAttachment($_FILES['file']['tmp_name']); // attachment $mail-&gt;Send(); echo "Story Request Sent Successfully&lt;/p&gt;\n"; } catch (phpmailerException $e) { echo $e-&gt;errorMessage(); //Pretty error messages from PHPMailer } catch (Exception $e) { echo $e-&gt;getMessage(); //Boring error messages from anything else! } ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload