Web Design and Development Forums

File Upload Contact Form

This is a discussion on "File Upload Contact Form" within the PHP Forum section. This forum, and the thread "File Upload Contact Form are both part of the Program Your Website category.


Go Back   Webforumz.com > Program Your Website > PHP Forum

Welcome to Webforumz.com.
Register Now Register now!

Reply
 
LinkBack Thread Tools Rate Thread
Old Apr 21st, 2008, 22:36   #1 (permalink)
Junior Member
 
Join Date: Apr 2007
Location: England
Posts: 44
File Upload Contact Form

Hey!
Well basicly I have made a contact form for users to apply for a job. I have made a php contact form before with relative ease, however i'm finding it hard to get their CV uploaded and attached to an email. I can get all the data put into a email and sent I just dont know how to attach the uploaded file. I took a look at how this company here do it (http://www.freeformmaker.com/) but I found their code really messy and hard to understand but if they can do it I'm sure its possible.

***UPDATE***

I created a code which should send the email and then upload the cv to the server and put a link to it in the email. However whenever I attach a word document it won't load and the error message I get is:

Code: Select all
the server unexpectedly dropped the connection, which sometimes occurs when the server is busy. You might be able to open the page later.
But I know it's not. Below is a copy of the form and the job_form.php that contains all the form scripting.

Code: Select all
<table width="412" height="280" border="0" align="center" cellpadding="0" cellspacing="1">
<tr>
<td width="410"><form action="job_form.php" method="post" enctype="multipart/form-data" name="jobform">
<p><span class="style3">Work With Us</span></p>
<table width="420" border="0" cellspacing="1" cellpadding="3">
<tr>
<td width="20%"><div align="right">Name</div></td>
<td width="3%">:</td>
<td colspan="2"><input name="name" type="text" id="name" size="30" /></td>
</tr>
<tr>
<td><div align="right">Surname</div></td>
<td>:</td>
<td colspan="2"><input name="surname" type="text" id="surname" size="30" /></td>
</tr>
<tr>
<td><div align="right">Email</div></td>
<td>:</td>
<td colspan="2"><input name="email" type="text" id="email" size="30" /></td>
</tr>
<tr>
<td><div align="right">Curriculum</div></td>
<td>:</td>
<td colspan="2"><input type="file" name="cv" id="cv" /></td>
</tr>
<tr>
<td><div align="right">Wanted</div></td>
<td>:</td>
<td colspan="2"><select name="wanted" id="wanted">
  <option value="collaboration">Collaboration</option>
  <option value="recruitment">Recruitment</option>
</select></td>
</tr>
<tr>
  <td><div align="right">What are you interested in</div></td>
  <td>:</td>
  <td width="39%" align="left" valign="top"><span class="style2">
    <label>
      <input type="checkbox" name="administration" id="administration" />
      Administration<br />  
      <input type="checkbox" name="commercial" id="commercial" />
      Commercial<br />  
      <input type="checkbox" name="lineworker" id="lineworker" />
      Line Worker<br />  
      <input type="checkbox" name="qualityoffice" id="qualityoffice" />
      Quality Office<br />  
      <input type="checkbox" name="miscellaneous" id="miscellaneous" />
      Miscellaneous</label>
  </span></td>
  <td width="38%" align="left" valign="top"><span class="style2">
    <label>
      <input type="checkbox" name="postsale" id="postsale" />
      Post Sale Technical Support</label>
    <br />
    <label>
    <input type="checkbox" name="warehouse" id="warehouse" />
    Warehouse</label>
    <br />
    <label>
    <input type="checkbox" name="secretary" id="secretary" />
    Secretary</label>
    <br />
    <label>
    <input type="checkbox" name="technicaloffice" id="technicaloffice" />
    Technical Office</label>
  </span></td>
</tr>
<tr>
  <td>&nbsp;</td>
  <td>&nbsp;</td>
  <td colspan="2"><input type="submit" name="Submit" value="Submit" />
    <input type="reset" name="Submit2" value="Reset" /></td>
</tr>
</table>
</form>
</td>
</tr>
</table>
PHP: Select all

<?php

@$pfw_ip$_SERVER['REMOTE_ADDR'];
@
$name addslashes($_POST['name']);
@
$surname addslashes($_POST['surname']);
@
$email addslashes($_POST['email']);
@
$cv_Name $_FILES['cv']['name'];
@
$cv_Size $_FILES['cv']['size'];
@
$cv_Temp $_FILES['cv']['tmp_name'];
@
$cv_Mime_Type $_FILES['cv']['type'];
@
$wanted addslashes($_POST['wanted']);
@
$administration addslashes($_POST['administration']);
@
$commercial addslashes($_POST['commercial']);
@
$lineworker addslashes($_POST['lineworker']);
@
$qualityoffice addslashes($_POST['qualityoffice']);
@
$miscellaneous addslashes($_POST['miscellaneous']);
@
$postsale addslashes($_POST['postsale']);
@
$warehouse addslashes($_POST['warehouse']);
@
$secretary addslashes($_POST['secretary']);
@
$technicaloffice addslashes($_POST['technicaloffice']);

function 
RecursiveMkdir($path)
 {
   if (!
file_exists($path)) 
   { 
      
RecursiveMkdir(dirname($path));
      
mkdir($path0777);
    }
  }


if (
strlen($name) == )
{
die(
"<p align='center'><font face='Arial' size='3' color='#008000'>Please enter a valid name</font></p>");
}

if (
strlen($surname) == )
{
die(
"<p align='center'><font face='Arial' size='3' color='#008000'>Please enter a valid surname</font></p>");
}

if (! 
ereg('[A-Za-z0-9_-]+\@[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+'$email))
{
die(
"<p align='center'><font face='Arial' size='3' color='#008000'>Please enter a valid email</font></p>");
}

if (
strlen($email) == )
{
die(
"<p align='center'><font face='Arial' size='3' color='#008000'>Please enter a valid email</font></p>");
}

if( 
$cv_Size == 0)
{
die(
"<p align='center'><font face='Arial' size='3' color='#008000'>Please enter a valid cv</font></p>");
}
if( 
$cv_Size >2000000)
{
 
unlink($cv_Temp);
die(
"<p align='center'><font face='Arial' size='3' color='#008000'>Please enter a valid cv</font></p>");
}
if( 
$cv_Mime_Type != "application/msword" AND $cv_Mime_Type != "application/pdf" AND $cv_Mime_Type != "application/rtf" AND $cv_Mime_Type != "application/zip" )
{
unlink($cv_Temp);
die(
"<p align='center'><font face='Arial' size='3' color='#008000'>Please enter a valid cv</font></p>");
}
$uploadFile "../uploads/".$cv_Name ;
if (!
is_dir(dirname($uploadFile)))
  {
    @
RecursiveMkdir(dirname($uploadFile)); 
  }
else
  {
  @
chmod(dirname($uploadFile), 0777);
  }
@
move_uploaded_file$cv_Temp $uploadFile); 
chmod($uploadFile0644);
$cv_URL "http://testdomain.com/uploads/".$cv_Name ;

$pfw_header "From: $email\n"
  
"Reply-To: $email\n";
$pfw_subject "Work With Us - RESPONSE";
$pfw_email_to "test@test.com";
$pfw_message "Visitor's IP: $pfw_ip\n"
"name: $name\n"
"surname: $surname\n"
"email: $email\n"
"cv: $cv_URL\n"
"wanted: $wanted\n"
"administration: $administration\n"
"commercial: $commercial\n"
"lineworker: $lineworker\n"
"qualityoffice: $qualityoffice\n"
"miscellaneous: $miscellaneous\n"
"postsale: $postsale\n"
"warehouse: $warehouse\n"
"secretary: $secretary\n"
"technicaloffice: $technicaloffice\n";
@
mail($pfw_email_to$pfw_subject ,$pfw_message ,$pfw_header ) ;

$pfw_header "From: test@test.com\n"
  
"Reply-To: test@test.com\n";
$pfw_subject "Thanks For Applying";
$pfw_email_to "$email";
$pfw_message "Thanks for applying to join the test team. We will get in contact with you as soon as possible.\n"
"\n"
"Regards,\n"
"\n"
"test";
@
mail($pfw_email_to$pfw_subject ,$pfw_message ,$pfw_header ) ;

 echo(
"<p align='center'><font face='Arial' size='3' color='#008000'>Your Application Has Been Recieved.</font></p>");
?>
Just another quick question - say somebody uploaded a file but there was already a file with the same name on the server, will the script give it a temp name?

Thanks in advance!

Last edited by jjpeacha; Apr 22nd, 2008 at 16:57. Reason: added php coding!
jjpeacha is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old Apr 24th, 2008, 12:03   #2 (permalink)
Junior Member
 
Join Date: Apr 2007
Location: England
Posts: 44
Re: File Upload Contact Form

Can anybody help?
jjpeacha is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old May 8th, 2008, 17:20   #3 (permalink)
Reputable Member
 
Join Date: Oct 2007
Location: Liverpool
Age: 29
Posts: 193
Re: File Upload Contact Form

In the Php section check out the post directly above this one!
longstand is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Tags
contact, form, php, upload

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
file upload berry05 Job Opportunities 0 Mar 19th, 2008 19:09
[SOLVED] PHP contact form redirect to same form Posie PHP Forum 14 Jan 29th, 2008 20:28
File Upload magiccupcake PHP Forum 1 Jan 22nd, 2007 05:10
File upload djme PHP Forum 4 Jan 11th, 2006 18:25
Need Quote Form and Contact Form Av8er Flash & Multimedia Forum 5 Oct 30th, 2003 17:14



Latest Updates

All Points SEO Security Advisory - CHECK YOUR SITE NOW!

Creative Coding :: February 2008

Webforumz is sponsored by: WESH UK Web Hosting
All times are GMT. The time now is 19:17.

Sleep Study Scoring :: Free Bet :: Website Templates :: Online Betting :: Bookmakers :: Funny Quotes :: Internet Recruitment Software :: Microsoft CRM Experts :: Online Casino :: Decorated Christmas Trees :: Midwife Forums :: Football Betting :: Ecommerce Software :: Web Hosting :: Football Stats :: Dry Cleaning Collection :: xtreme wales - extreme clothing :: Apuestas :: Sharepoint Consultants :: Website Optimisation :: Office Clearance London :: Sharepoint Experts :: Sports Betting :: Casino :: Website Templates :: Web Design Development India :: Online Gambling

Powered by: vBulletin Version 3.7, Copyright ©2000 - 2008, Jelsoft Enterprises Limited.
© 2003-2008 Webforumz.com : All Rights Reserved
Search Engine Friendly URLs by vBSEO 3.2.0 RC6


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59