Having file upload boxes in contact forms will be greatly convenient for some web sites. For example, if the visitor can attach his/her photo and resume, that will greatly enhance the form's functionality. Here is a contact form that you can customize for your needs.
Download the contact form code
You can download the contact form that best fits your needs and then customize as required.
Features of the contact form
- You can have any number of file upload boxes
- Standards compliant (100% XHTML 1.0 strict validated, uses CSS)
- Secured against spam bots and attacks
- Easy to customize
- Hosted on your own web server
- Free!
Installing the contact form on your web site
- Unzip the downloaded contact form code.
- Edit contactform.php and edit the email address to your email address
- Upload the folder contents to your website (to a sub-folder say,
/contact) - The contactform.php contains the form. You can link to this file or embed the form using iframe.
$formproc->AddRecipient('name@your-website.com');//<<---Put your email address here
Here is sample iframe code to embed the form:
<iframe src='/contact/contactus.php' frameborder='0' width='100%' height='600' ></iframe>
Alternatively, you can modify contactform.php to have the same look of your web site.
Customizing the form
If you want to add one more file upload box, do the following:
- open contactus.php in a text editor
- Add the HTML code for the file upload box(just like the existing one for the photo). Gove another unique name and id for the file upload box
- Add one more line on the top of the contactus.php
<div class='container'>
<label for='photo' >Another upload:</label><br/>
<input type="file" name='newupload' id='newupload' /><br/>
<span id='contactus_newupload_errorloc' class='error'></span>
</div>
$formproc->AddFileUploadField('photo','jpg,jpeg,gif,png,bmp',2024);
$formproc->AddFileUploadField('resume','doc,docx,pdf,txt',2024);
$formproc->AddFileUploadField('newupload','',2024);//<<------- New file upload
You can edit the contact.css file to change the style of the form.
License

The code is shared under LGPL license. You can freely use it on commercial or non-commercial websites.
Related posts:







{ 138 comments… read them below or add one }
← Previous Comments
hi, great form… mines working perfectly with a few of my own css and tweaks… BUT, is there a way to put the error messages in a separate div??
my form is hidden in a ‘show/hide’ div and when the form is filled out incorrectly the div re-sets and hides the form. So if someone does fill it out wrong they are unaware… i need the error messages to be displayed in a separate div like a separate container or column…
anyone got an idea???
I’ve been looking for a way to allow users to send pictures to me through my blog. This is the best solution I found. Thank you very much
Hi, form was very easy to install – so big thanks for that…I just got one problem,
I’m trying to add more file formats such as .doc, .txt etc.
so where do I need to upload this line and do I need to change something in validation query?
$formproc->AddFileUploadField(‘resume’,'doc,docx,pdf,txt’,2024);
I’m total newbie and been learning html/php only for the last 2 months..so plz help me out..
Thanks
Hi,
Just wanted to say a massive thank you for this. I’ve been trying to get a basic form on my site for two days! Non of the other scripts worked for me, but this worked like a charm.
TIP: Once you have downloaded the the file, unzip it directly into your website folder. That way files will by linked with each other without you having to change any text/codes (apart from one, which is the email you want it sent two).
I’m using Dreamweaver CS5, hosted by: 000webhost.
Now just need to tweak it to my taste!
Nice work for this, this is very helpful, thumbs up for you guys but how to remove this kind of error? I ecountered that error after I sent the message instead of thank-you.php
thanks a lot and I’m hoping for the response.
Deprecated: Function eregi() is deprecated in /home/akai1831/public_html/contact/include/fgcontactform.php on line 548
Deprecated: Function split() is deprecated in /home/akai1831/public_html/contact/include/class.phpmailer.php on line 470
I’m getting the same problem on xampp.
Deprecated: Function eregi() is deprecated in C:\xampp\htdocs\dailyrozgar\contactUs\include\fgcontactform.php on line 548
So, what is the solution please?
Hello if i use the iframe how can i set the link page to appear in the same window and not in the iframe? where to put target=”_top” ?
Form works in that it sends email, but not attachments. The email lists the files to be uploaded, but the email has no attachments.
how to create a contact form on xampp?
how to connect to the database?
and what field created in the database?
wow…it’s working fine.
Got the form working great for customers to send us a logo. Customers also has to specify 4 SKU #s in order for us to make customized sewing machine needle gift boxes for them. When you look at the page there is a lot of empty real-estate to the right of the form. Here’s my question: Colleague is wondering if I can add a list of SKU’s to the space to the right of the form. I’ve been banging my head against the wall trying to come up with a solution. The code as currently generated doesn’t allow me to do any editing/adding to the right of the form. I’ve tried to set up a a two-column page with the form on the left and my SKU’s on the right . . . unfortunately, things become hopelessly messed up. Anyone have any solutions????
Hi, i am using a php form with file upload, and everything works great except i dont get the uploaded file such as jpg to my gmail, please help
thanks
Hello, i can’t align the iframe on the center on my home page, do you know how i can do this, i try a lot of solution but nothing work. Thanks
hi.. please tell me how to change above coding if i dont want send the uploaded file to my email, but to my directory website. cause maybe visitor upload big size file. sorry i am still newbie in PHP. thx before
Perfect, it works
I keep getting
“Automated submission prevention: case 1 failed”
Even when I fill out the demo forms? Does anybody know why?
I set up form which worked nicely till i tried it with Internet Explorer. It doesn’t work at all! I have all the latest updates for it, and still don’t do the trick. Why it doesn’t support IE? With Mozilla it works just fine.
Please try the sample forms in this page in IE. Does it work?
I may have cried a bit too early. I made the whole form again and now it seem to work – phew!
← Previous Comments