Click to See Complete Forum and Search --> : I am trying to make a form
FireBall
08-04-2005, 02:11 AM
that will allow people to upload a pic to my email addy thru the website? if it is poss i have been trying to do this for a week by rewriting reg form codes to no avail. i will be getting my server space back soon aso that may be what i need not sure.
if anyone can help a fellow webmaster out i would say thanks many times. :)
thank you in advance FireBall
beanroaster
08-05-2005, 12:06 AM
Is this what you are looking for?
<input type="file" />
Good Luck,
Adam
FireBall
08-05-2005, 12:14 AM
i have that part of the code and the rest of the form coding but when i do send the email from the site the image doesnt go with the mail only a email full of encryption or nonsense your choice of words for it lol. i am tinkering with a database program now to set on my personal tower and a link to upload the images directly to it instead of email.
BeachSide
08-05-2005, 01:03 AM
you can't just send an attachment like that.
Check this link out...
http://www.sitepoint.com/article/advanced-email-php
FireBall
08-05-2005, 01:42 AM
ok i used the send mail php code and it runs perfect for the regular emails but will not send the file thru to my email regardless if i am on IE or FireFox. any ideas i will post the php code in a box for ya to look at and see if i am missing something important.
FireBall
08-05-2005, 01:47 AM
sorry for the lengthy reply but i dont see where i messed up at
thank you in advance.
<html>
<head>
<title> Sending Email </title>
</head>
<body>
<?php
// Read POST request params into global vars
$to = $_POST['to'];
$from = $_POST['from'];
$subject = $_POST['subject'];
$message = $_POST['message'];
// Obtain file upload vars
$fileatt = $_FILES['fileatt']['tmp_name'];
$fileatt_type = $_FILES['fileatt']['type'];
$fileatt_name = $_FILES['fileatt']['name'];
$headers = "From: $from";
if (is_uploaded_file($fileatt)) {
// Read the file to be attached ('rb' = read binary)
$file = fopen($fileatt,'rb');
$data = fread($file,filesize($fileatt));
fclose($file);
// Generate a boundary string
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
// Add the headers for a file attachment
$headers .= "\nMIME-Version: 1.0\n" .
"Content-Type: multipart/mixed;\n" .
" boundary=\"{$mime_boundary}\"";
// Add a multipart boundary above the plain message
$message = "This is a multi-part message in MIME format.\n\n" .
"--{$mime_boundary}\n" .
"Content-Type: text/plain; charset=\"iso-8859-1\"\n" .
"Content-Transfer-Encoding: 7bit\n\n" .
$message . "\n\n";
// Base64 encode the file data
$data = chunk_split(base64_encode($data));
// Add file attachment to the message
$message .= "--{$mime_boundary}\n" .
"Content-Type: {$fileatt_type};\n" .
" name=\"{$fileatt_name}\"\n" .
//"Content-Disposition: attachment;\n" .
//" filename=\"{$fileatt_name}\"\n" .
"Content-Transfer-Encoding: base64\n\n" .
$data . "\n\n" .
"--{$mime_boundary}--\n";
}
// Send the message
$ok =dbinagia@austin.rr.com($to, $subject, $message, $headers);
if ($ok) {
echo "<p>Mail sent! Yay PHP!</p>";
} else {
echo "<p>Mail could not be sent. Sorry!</p>";
}
?>
</body>
</html>