Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PHPmailer to send attachment input to form (several formats) 2

Status
Not open for further replies.

jlockley

Technical User
Nov 28, 2001
1,522
US
Using PHPmailer to gather information and a document to be mailed to my own account. Cannot get the upload correct. The infomation I can find is cofusing.

The form upload is the usual:
</tr>
<tr>
<td style="width: 1085px" class="style2" valign="top">Upload resume</td>
<td style="width: 1184px">
<input name="resume" type="file" size="45" /></td>

</td></tr>

The form handler is
<DOCTYPE HTML PUBLIC
"-//W3C//DDT HTML 4.01 Transitional//EN"
"
<html>
<head>
<title>Contact and sign up</title>
<link rel="stylesheet" type="text/css" href="phpmailerform.css">

</head>
<body>

<div class="style7"><h3><p>To register with us please fill out the following fields and upload a resume.</P>
<p>The files marked with * are required. The rest will make it easier for us to pick your resume. To be placed on our newsletter and job alert list, click the button at the end</p></h3></div>
<form action="process_form.php" method="POST" enctype='multipart/form-data'>
<table style="width: 792px; height: 553px" cellspacing="5" class="style4">
<tr>
<td style="width: 1085px" class="style2" valign="top">Last Name</td>
<td style="width: 1184px">
<input name="last_name" type="text" size="50" ></td>
</tr>
<tr>
<td style="width: 1085px" class="style2" valign="top">First</td>
<td style="width: 1184px">
<input name="first" type="text" size="50" ></td>
</tr>

<tr>
<td style="width: 1085px" class="style2" valign="top">EMail</td>
<td style="width: 1184px">
<input name="email" type="text" size="50" ></td>
</tr>

<tr>
<td style="width: 1085px" class="style2" valign="top">Cell Phone </td>
<td style="width: 1184px">
<input name="cell" type="text" size="50" /></td>
</tr>
<tr>
<td style="width: 1085px" class="style2" valign="top">Phone</td>
<td style="width: 1184px">
<input name="phone" type="text" size="50" /></td>
</tr>
<tr>
<td style="width: 1085px" class="style2" valign="top">City</td>
<td style="width: 1184px">
<input name="city" type="text" size="50" /></td>
</tr>
<tr>
<td style="width: 1085px" class="style2" valign="top">State</td>
<td style="width: 1184px">
<input name="state" type="text" size="50" /></td>
</tr>
<tr>
<td style="width: 1085px" class="style2" valign="top">Zip</td>
<td style="width: 1184px">
<input name="zip" type="text" size="50" /></td>
</tr>
<tr>
<td style="width: 1085px" class="style2" valign="top">Current
position/title</td>
<td style="width: 1184px">
<input name="position" type="text" size="50" /></td>
</tr>
<tr>
<td style="width: 1085px" class="style2" valign="top">Current
Current or last position at</td>
<td style="width: 1184px">
<input name="location" type="text" size="50" /></td>
</tr>
<tr>
<td style="width: 1085px; " class="style2" valign="top">
Employer type (restaurant, hotel, Club, etc)</td>
<td style="width: 1184px">
<input name="type" type="text" size="50" /></td>
</tr>
<tr>
<td style="width: 1085px" class="style2" valign="top">Desired
location</td>
<td style="width: 1184px">
<input name="Text16" type="text" size="50" /></td>
</tr>
<tr>
<td style="width: 1085px" class="style2" valign="top">Training or
education</td>
<td style="width: 1184px">
<input name="training" type="text" size="50" /></td>
</tr>
<tr>
<td style="width: 1085px; height: 40px;" class="style2" valign="top">Special skills(Asian, comfort, etc)</td>
<td style="width: 1184px; height: 40px;">
<input name="skills" type="text" size="50" /></td>
</tr>
<tr>
<td style="width: 1085px" class="style2" valign="top">
Culinary Style</td>
<td style="width: 1184px">
<input name="styles" type="text" size="50" /></td>
</tr>
<tr>
<td style="width: 1085px" class="style2" valign="top">
Comments</td>

<td style="width: 1184px">
<textarea name="comments" cols="45" rows="5"></textarea></td>


</tr>
<tr>
<td style="width: 1085px" class="style2" valign="top">Upload resume</td>
<td style="width: 1184px">
<input name="resume" type="file" size="45" /></td>

</td></tr>

</table>


<?php
require_once('recaptchalib.php');
$publickey = "6LcVxwcAAAAAAIgVQ17ZYXbikv6VBpEEmTztdqYA"; // you got this from the signup page
echo recaptcha_get_html($publickey);




?>

// <p><input type="submit" value="send" /p><br/>


</form>
</body>
</html>

Obviously something is missing.
I have been playing with this but
1) It forwards the file from an upload directory. How is the file directed to /uploads ?
2) this is written for an image file. I expect various document formats.
3) I added
$dir = "uploads/$filename";
(/uploads/ is already set to full permissions, so the chmod() function, which creates an error string anyway, is unnecessary). This creates an error message. /uploads is in the document directory.
4) Does the uploaded document have to placed in an array?

What I would really like to do is rename the uploaded document to $first.$last.$title with some string manipulation, but $POST_['resume'] creates the error
Notice: Undefined index: resume in /home/jll/public_html/process_form.php on line 68
Message has been sent.
 
are you trying to store the document and the data input into the form as well as send it by phpmailer?
 
When your form is submitted, the file is uploaded to your server. Since its a file its not going to be in the $_POST array but rather the $_FILES array.

With that said, you can use the move_uploaded_file() function to manipulate the file.






----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
or just use

Code:
$phpMailer->AddAttachment($_FILES['resume']['tmp_name'], $_FILES['resume']['name'], 'base64', $_FILES['resume']['type']);
 
Terrific...Thank you both. I read up on uploading, and as soon as I figure out where it is, I will implement this. I have a couple of things I want to attempt. We will see if they work.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top