PDA

View Full Version : attach file php form



Magiccupcake
06 Aug 2007, 02:14 PM
I need a form that will send info from a site to my email. It also needs to be able to allow attachments (mostly .jpg & .gif)

Right now I have been using this and it works very well but I can not add attachments.

Does anyone know what I need to do to fix this?



<?php
//--------------------------Set these paramaters--------------------------

// Subject of email sent to you.
$subject = 'upload test form';

// Your email address. This is where the form information will be sent.
$emailadd = 'mat@webofamerica.net';

// Where to redirect after form is processed.
$url = 'http://www.webofamerica.net';

// Makes all fields required. If set to '1' no field can not be empty. If set to '0' any or all fields can be empty.
$req = '0';

// ----------------------------------------------------

$text = "Results from form:\n\n";
$space = ' ';
$line = '
';
foreach ($_POST as $key => $value)
{
if ($req == '1')
{
if ($value == '')
{echo "$key is empty";die;}
}
$j = strlen($key);
if ($j >= 20)
{echo "Name of form element $key cannot be longer than 20 characters";die;}
$j = 20 - $j;
for ($i = 1; $i <= $j; $i++)
{$space .= ' ';}
$value = str_replace('\n', "$line", $value);
$conc = "{$key}:$space{$value}$line";
$text .= $conc;
$space = ' ';
}
mail($emailadd, $subject, $text, 'From: '.$emailadd.'');
echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';
?>