Have added the following:
Upload aspect of form
HTML Code:
enctype="multipart/form-data
HTML Code:
<tr>
<td class="size"><p class="size">Please upload a photograph of yourself</p></td>
<td class="stuff"><input type="file" name="uploaded_file"></td>
</tr>
Mailer aspect of form (class) changed
PHP Code:
<?php
if(isset($_POST['submit'])) {
$to = "email";
$subject = "Pilot Card Application";
$title = $_POST['title'];
$first = $_POST['first'];
$last = $_POST['last'];
$day = $_POST['day'];
$month = $_POST['month'];
$year = $_POST['year'];
$address = $_POST['address'];
$tel = $_POST['tel'];
$email = $_POST['email'];
$option = $_POST['radio'];
$dropdown = $_POST['drop_down'];
$other = $_POST['other'];
$header = "From: $email <$email>";
$where = $_POST['where'];
$comments = $_POST['comments'];
//Get the uploaded file information
$name_of_uploaded_file =
basename($_FILES['uploaded_file']['name']);
//get the file extension of the file
$type_of_uploaded_file =
substr($name_of_uploaded_file,
strrpos($name_of_uploaded_file, '.') + 1);
$size_of_uploaded_file =
$_FILES["uploaded_file"]["size"]/1024;//size in KBs
//Settings
$max_allowed_file_size = 5120; // size in KB
$allowed_extensions = array("jpg", "jpeg", "gif", "bmp");
$upload_folder = './uploads/'; //<-- this folder must be writeable by
the script
//Validations
if($size_of_uploaded_file > $max_allowed_file_size )
{
$errors .= "\n Size of file should be less than
$max_allowed_file_size";
}
//------ Validate the file extension -----
$allowed_ext = false;
for($i=0; $i<sizeof($allowed_extensions); $i++)
{
if(strcasecmp($allowed_extensions[$i],$type_of_uploaded_file) == 0)
{
$allowed_ext = true;
}
}
if(!$allowed_ext)
{
$errors .= "\n The uploaded file is not supported file type. ".
" Only the following file types are supported:
".implode(',',$allowed_extensions);
}
//copy the temp. uploaded file to uploads folder
$path_of_uploaded_file = $upload_folder . $name_of_uploaded_file;
$tmp_path = $_FILES["uploaded_file"]["tmp_name"];
if(is_uploaded_file($tmp_path))
{
if(!copy($tmp_path,$path_of_uploaded_file))
{
$errors .= '\n error while copying the uploaded file';
}
}
include_once('PEAR/Mail.php');
include_once('PEAR/Mail/mime.php');
$message = new Mail_mime();
$message->setTXTBody($text);
$message->addAttachment($path_of_uploaded_file);
$body = "Transport Pilot Application from $title $first $last\n\n Title: $title\n First Name: $first\n Last Name: $last\n\n Date of Birth: $day / $month / $year\n\n Address:\n$address\n\n Telephone Number: $tel\n Email: $email\n\n School: $dropdown\n Other: $other\n\n Data Protection: $option\n\n $first heard about the scheme from: $where\n\n Other Comments: $comments";
$extraheaders = array("From"=>$from,
"Subject"=>$subject,"Reply-To"=>$email);
$headers = $message->headers($extraheaders);
$mail = Mail::factory("mail");
$mail->send($to, $headers, $body);
echo
"<font=verdana><p align=center><b>Thank you for applying for the East
Riding Youth Assembly's transport card. <br /> Somebody will get back to
you within a few days.</p><br /><p align=center>If you have any further
enquiries, please contact email or call
number</p></b></font>";
} else {
echo "blarg!";
}
?>
After installing PEAR, I have included PEAR/Mail.php and PEAR/Mail/mime.php. This works well, but when it comes to include the mimePart.php, I believe it is looking in /home/erya/public_html/beta/PEAR/Mail/mime.php/Mail/mimePart.php, instead of /home/erya/public_html/beta/PEAR/Mail/mimePart.php. Is it possible to rewrite this?
Warning: require_once(Mail/mimePart.php) [function.require-once]: failed to open stream: No such file or directory in /home/erya/public_html/beta/PEAR/Mail/mime.php on line 74
Fatal error: require_once() [function.require]: Failed opening required 'Mail/mimePart.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/erya/public_html/beta/PEAR/Mail/mime.php on line 74
Adam.