Introduction
Nowadays most of the clients want extra fields in contacts form of Magento to fulfill their requirements. And adding custom fields other than upload field (for example text, textarea, select, etc) in the contact form are easy in the sense you can easily include the field values in the contact email template.
But adding upload field can be trickier as you have to process the file upload operation and attach it with your email contents.
Steps
1. Modify the contact form template
You need to modify the contact form template file: app/design/frontend/[your-interface]/[your-theme]/template/contacts/form.phtml:
a> Add enctype=”multipart/form-data” in <form> element as:
b> Add file upload field below ‘Comment’ field (or anywhere you want) as:
2. Create controller class for processing file upload
Next step is to override the Mage_Contacts_IndexController class.
For this, you need to create a custom module. For the tutorial purpose, I am assuming Namespace to be ‘MagePsycho’ and Module to be ‘Customcontact’.
a> Add XML override code in your module’s config.xml as:
b> Create your custom controller
Create a controller file in your module dir as app/code/local/MagePsycho/Customcontact/controllers/IndexController.php
and copy the following code:
3> There you go.
Try to attach file and submit the contact form, you will get that file as an attachment in contact email.
[Snapshots]
Hope this helps you.
Happy E-Commerce!