We were unable to load Disqus. If you are a moderator please see our troubleshooting guide.

Prash • 3 years ago

This is not working.. Try this.. works perfect ! http://www.magentocommerce....

mc_bosc • 9 months ago

_____________FINAL FIX
avalancha = magepsycho (Check CAP leters Magento very sketchy)

IndexController.php replace this line with (or add /)
$fileName = preg_replace('/\s+/', '', $fileNamewoe) . time() . '.' . $fileExt;

\app\code\local\Avalancha\Customcontact\etc\config.xml

<config>
<modules>
<avalancha_customcontact>
<version>1.0.0</version>
</avalancha_customcontact>
</modules>
<frontend>
<routers>
<contacts>
<args>
<modules>
<customcontact before="Mage_Contacts">Avalancha_Customcontact</customcontact>
</modules>
</args>
</contacts>
</routers>
</frontend>

</config>

\app\etc\modules\Avalancha_Customcontact.xml

<config>
<modules>
<avalancha_customcontact>
<active>true</active>
<codepool>local</codepool>
</avalancha_customcontact>
</modules>
</config>

you can thks me or like in my instagram/twitter @mc_bosc its free

www.Latinporn.pw • 1 year ago

thanks for these methods however if they need help here is one file hosting - http://anonyfile.space

DSha • 1 year ago

I've worked for hours on this and though the email comes through there is no attachment. Tried all the suggestions in this thread and other threads by individuals with similar problems adding attachments to the contact form. Baffling how some people here get it to work. It would be helpful if someone who this actually works for would clue all of us in on the details that these instuctions leave out.

Unfortunately the link below from "Prash" doesn't work anymore either, I'd gladly embrace an alternative solution. Suprising that for a platform as popular as Magento that the simple enabling of the contact form with an attachment functionality seems to be such a frustrating endeavour for a large percentage of the people trying to accomplish it.

Nersus • 1 year ago

Hi!

This works for me:

Replace:

$attachmentFilePath = Mage::getBaseDir('media'). DS . 'contacts' . DS . $fileName;
if(file_exists($attachmentFilePath)){

$fileContents = file_get_contents($attachmentFilePath);

$attachment = $mailTemplate->getMail()->createAttachment($fileContents);

$attachment->filename = $fileName;

}

for:

$attachmentFilePath = Mage::getBaseDir('media'). DS . 'contacts' . DS . $fileName;

if(file_exists($attachmentFilePath)){

$fileContents = file_get_contents($attachmentFilePath);

$mailTemplate->getMail()->createAttachment($fileContents,

Zend_Mime::TYPE_OCTETSTREAM,

Zend_Mime::DISPOSITION_ATTACHMENT,

Zend_Mime::ENCODING_BASE64,

$fileName);

}

Sagar • 1 year ago

Hi,

I did this and able to bring Attachment button. But there are no attachments with the email. Can anyone tell how to rectify this

Regards
Sagar

Calum • 2 years ago

Do I replace the entire block of code inside config.xml currently? -

<frontend>
<routers>
<contacts>
<use>standard</use>
<args>
<module>Mage_Contacts</module>
<frontname>contacts</frontname>
</args>
</contacts>
</routers>
<translate>
<modules>
<mage_contacts>
<files>
<default>Mage_Contacts.csv</default>
</files>
</mage_contacts>
</modules>
</translate>
<layout>
<updates>
<contact>
<file>contacts.xml</file>
</contact>
</updates>
</layout>
</frontend>

Guest • 2 years ago

Thanks for this great post, its working for me, i want to upload multiple image, please help me.
Thanks

Danny • 2 years ago

it work! Magento 1.9, just copy the contact module to another new and add the code for attach a file and work!

Thanks men, +10

Jason Wong • 1 year ago

Did you place the Contacts form into a CMS page?
How about adding Magento's core CAPTCHA into the form after the file attachment field?

Please share what and how you did to get it to work. I'm using Magento 1.9.2.1.

Thank you.

Mary Johnson • 2 years ago

You had done great job for us. But i want some advance features regarding Products Attachments. Thats why i was compell to install an updated Extension. If any one needed that Module they can get it from this URL link:http://www.fmeextensions.co...

Ramya Gunasekar • 2 years ago

i added extra field in contact form that is attachment field i follow the above steps but still am getting error "unable to submit try again later".. plz help me

Conative IT Solutions • 2 years ago

can you tell where this contact form data is stored in magento

Vikas • 3 years ago

Thnx for you post. It is working perfect.
i thing you miss one thing .
create xml file MagePsycho_Customcontact.xml in app/etc/modules/MagePsycho_Customcontact.xml

<config>
<modules>
<magepsycho_customcontact>
<active>true</active>
<codepool>local</codepool>
</magepsycho_customcontact>
</modules>
</config>

juhulian • 3 years ago

Thx for your great post!!
First, I think you've got a typing mistake in your IndexController on line 3.
Then, what about the error messages, if for example, the file extension is wrong?
greetings

droman • 4 years ago

I think I'm having problems coding the config.xml (Namespace: Newform / Module name: Customcontacts). I have this so far but I don't know if it is correct:

0.0.1

Newform_Customcontacts

Does someano know if this xml file has an error?

Thanls for your time.

khushbu • 4 years ago

i am uploading pdf file "AIO Printer.pdf" while file uploaded to corresponding folder in filename space is replaced by "_" so in server file exists with AIO_printer.pdf but at this line

$attachmentFilePath = Mage::getBaseDir('media'). DS . 'contacts' . DS . $fileName;
if(file_exists($attachmentFilePath))
{
}
it shows file does not exists & redirects me to else portion

Matthew • 4 years ago

Everything seems to work fine, except the IndexController.php

For whatever reason, it is unable to attach the image to email, and it's not even adding the image into the media/contacts directory either.

Can you provide a solution?

droman • 4 years ago

One bug that I found in the php code is found in line 41:

$fileName = preg_replace('/\s+', '', $fileNamewoe) . time() . '.' . $fileExt;

The missing part is the delimiter ' / ', so the code would be like this:

$fileName = preg_replace('/\s+/', '', $fileNamewoe) . time() . '.' . $fileExt;

The problem that i encoutered coding this extension is that mi config.xml is having trouble finding the code, module, etc. to override, so I decided to paste part of the php code (the part of finding and uploading the attachment) in the app/code/core/Mage/contacts/IndexController.php in order to avoid overriding. So far the document is uploaded to the server but the part that is not working is sending the email with the attachment.

droman • 4 years ago

You also have to consider modifying line 44 for accepting image extensions:

$uploader->setAllowedExtensions(array('doc', 'docx','pdf'))

As you can see, the code is currently just accepting Microsoft Word and pdf files.

Purushotam sharma • 4 years ago

Please simplify the second steps, we didn't get any effect of this code......

stephanie • 4 years ago

I did this tutorial 3 times and still the same result. The email form is fine (the upload buttons are there), but no images are attaching to the email. Please help!!!

Luis • 4 years ago

hello:

modify
form.html
app/code/core/Mage/Contacts/etc/config.xml
add
app/code/local/MagePsycho/Customcontact/controllers/IndexController.php

context menu
Contatti

error:
Whoops, our bad...

??

TKS

Victor • 4 years ago

I'm not sure what i'm doing wrong. I have done what you say but it didn't work. Maybe the first step have to be in an specific place? (the form I mean).

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 element as:

Thank you and best regards,