Php script with email attachment help

I need to add a field that will allow a student to attach thier photo to theonlin application form on our website that will be sent to our email address along with the form data.

Here is the current script that send the email to us:
[php]<?php

//--------------------------Set these paramaters--------------------------

$subject = ‘New Homestay Application’; // Subject of email sent to you.
$emailadd = ‘[email protected]’; // Your email address. This is where the form information will be sent.
$url = ‘http://yourdomain.com/forms/thankyou.html’; // Where to redirect after form is processed.
$req = ‘0’; // 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.

// --------------------------Do not edit below this line--------------------------
$text = “Results from Application 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)

$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 ‘’;
?>[/php]

We have used this form and script for the past 5 years and it works just fine with no problems at all. However now I need to add a field so the student can send us thier current photo with the form data in a jpg, gif or png format.

Can someone please help me with this problem. I have read so many post on this and just can not wrap my head arround it and I am at a total loss.

Kindest Regards
and many thanks in advance for your professional help.
You can view the working Application form at www.thedewberry.com

I’ve never used email attachments in PHP mail, but there’s a script here that you can edit. It appears you need to base64 encode it and add it to the header.

Thank you for your reply. However I have an existing form that is very larg we have been suing for student applications for the past 5 years and I realt do not want to rewright it. I was hoping to use the existing script and form and just adding the info I need to accomplish this task. If this is not possable to do, I guess we will just have to leave it and find another way. Thank You for your time.

Just chop the attachment bit out of the code and use it in your existing form?

Well obviously with that answer I see I came to the wrong Php help site. Don’t you think I have tried all of this before coming here for help from the pros. My mistake will look els ware for professional help. Sorry to have bothered you.

Sponsor our Newsletter | Privacy Policy | Terms of Service