Add file upload to the standard contact form

Artem - June 5, 2006 - 12:57

1. My site users often need to send me some files
2. I am afraid of spammers and prefer not to publish my email -> I ask everybody use the site's "contact us" form (standard Drupal's)

Is there a way to allow attaching files to the "Contact us" form? Maybe some special "Contact Us" module?

Try webform

laura s - June 5, 2006 - 13:07

You can define your own fields. I'm not sure if it has provision for attachments, though.

Laura
_____ ____ ___ __ _ _
design, snap, blog

Thank you, I'll have a look

Artem - June 5, 2006 - 15:49

Thank you, I'll have a look at it.

take a look here

Creazion - June 11, 2006 - 08:36

Hi Artem,

look here http://drupal.org/node/68265. I've post a solution for a contact form with file attachment and an anti spam filter.

---------------------------------------------------
You find me at www.creazion.de
My last project www.happy-faces.de

Unfortunately, I afraid, my

Artem - June 13, 2006 - 12:36

Unfortunately, I afraid, my PHP/Drupal skills are too low to correctly use the Drupal code that is not packaged into a module

Don't be afraid just copy & paste

Creazion - June 13, 2006 - 23:19

Hi Artem,

the code is very easy to use.

Follow the steps to create your custom contact form:

  1. create a new page
  2. copy the code from http://drupal.org/node/68265
  3. paste the code in the body field
  4. select the php filter for your new page
  5. create a new menu item to the page
  6. and save

now you have a new contact form with the ability to attach files.

You have only to customize the following block:

<?php


    $from       
= $form_values['name'].' <'.$form_values['eMail'].'>';
   
$recipient    = 'YOUR NAME <name@domain.com>';
   
$subject    = $form_values['subject'];
   
$body        = wordwrap($form_values['message']);
   
$reply        = 'Thank you for your message.';
   
$goto        = '<front>';
?>

I think it's self explanation. But if you've any questions to this script let me hear them I will help you.

---------------------------------------------------
You find me at www.creazion.de
My last project www.happy-faces.de

Thank you, Creazion I'll try

Artem - June 14, 2006 - 10:06

Thank you, Creazion

I'll try it.

Don't be afraid just copy & paste

PAAHCweb - June 14, 2006 - 14:39

That sentence should have its own page in the handbook. :^)

Thanks a Ton!

erikhanson - July 27, 2006 - 21:08

Worked like a charm, thanks for the work on the code for this. Would be nice to have this as an option for sepecific contact form (built into the Drupal core). Anyway, good solution to the contact form attachment issue.

Creazion - thanks for the post

udijw - August 30, 2006 - 21:48

I used the sugested code and it works great.
Is there a way I can set the uploader so it will only allow certain file types to be uploaded (eg .png, .gif and .jpg)?
thanks again,
Udi.
my site - DIY Studio Photography and lighting

This is what I'm looking

tjblair - June 6, 2007 - 23:34

This is what I'm looking for. However after I copy the text into the Body and save I get the following message instead of the new contact form.

warning: call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, 'contactform' was given in /home/vancouw2/public_html/drupal/includes/form.inc on line 218.

Does anyone know what I'm missing?
I'm using Drupal 5.1

I get the same error when I

grippat - June 8, 2007 - 16:13

I get the same error when I try to use the code on Drupal 5.1 as well. I'm not sure what's causing it though.

code for drupal v5

aufumy - September 28, 2007 - 18:39

I used creazion's updated example for version 5, and it works fine.

http://drupal.org/node/68265#comment-212470

custom form

bharanikumariyerphp - May 3, 2008 - 09:58

hi dear i design the form ..
i savedthat form in the theme folder tell me..

now i want to display that form in the user page...
with menu name:: student register and its forms must display..
thanks in advance

problem with drupal v6

zhufrk - May 23, 2008 - 00:24

Hi, I plugged the code in a page, and get this error when saving. Any idea how to fix it is appreciated.
=====================
warning: call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, 'contactform' was given in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\pedb_drupal\includes\form.inc on line 358.
=====================

 
 

Drupal is a registered trademark of Dries Buytaert.