Click to See Complete Forum and Search --> : prefilled form with images?


lukeurtnowski
07-15-2006, 01:51 PM
I get an email...But is just text (jibberish) where the image should be.
heres my code...

..
$Who = $_POST["Who"];

// Obtain file upload vars
$Image1 = $_FILES['Image1']['tmp_name'];
$Image1_type = $_FILES['Image1']['type'];
$Image1_name = $_FILES['Image1']['name'];
$Image2 = $_FILES['Image2']['tmp_name'];
$Image2_type = $_FILES['Image2']['type'];
$Image2_name = $_FILES['Image2']['name'];
$Image3 = $_FILES['Image3']['tmp_name'];
$Image3_type = $_FILES['Image3']['type'];
$Image3_name = $_FILES['Image3']['name'];
$Image4 = $_FILES['Image4']['tmp_name'];
$Image4_type = $_FILES['Image4']['type'];
$Image4_name = $_FILES['Image4']['name'];
$Image5 = $_FILES['Image5']['tmp_name'];
$Image5_type = $_FILES['Image5']['type'];
$Image5_name = $_FILES['Image5']['name'];
$Image6 = $_FILES['Image6']['tmp_name'];
$Image6_type = $_FILES['Image6']['type'];
$Image6_name = $_FILES['Image6']['name'];

$to = "admin1sdasp@gmail.com"; // change this to your email
$subject = "SDASP PAGE REQUEST";

$message = "These are the values that a user has tried to submit<br />";
$message .= '<form method=post action="http://testing.scasp.com/update_table_provider.php"><br />';
..
if (is_uploaded_file($Image1)) {
// Read the file to be attached ('rb' = read binary)
$file = fopen($Image1,'rb');
$data = fread($file,filesize($Image1));
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/html; 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: {$Image1_type};\n" .
" name=\"{$Image1_name}\"\n" .
//"Content-Disposition: attachment;\n" .//change to inline if you want.
//" filename=\"{$fileatt_name}\"\n" .
"Content-Transfer-Encoding: base64\n\n" .
$data . "\n\n" .
"--{$mime_boundary}--\n";
}
if (is_uploaded_file($Image2)) {
// Read the file to be attached ('rb' = read binary)
$file = fopen($Image2,'rb');
$data = fread($file,filesize($Image1));
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/html; 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: {$Image2_type};\n" .
" name=\"{$Image2_name}\"\n" .
//"Content-Disposition: attachment;\n" .//change to inline if you want.
//" filename=\"{$fileatt_name}\"\n" .
"Content-Transfer-Encoding: base64\n\n" .
$data . "\n\n" .
"--{$mime_boundary}--\n";
}
if (is_uploaded_file($Image3)) {
// Read the file to be attached ('rb' = read binary)
$file = fopen($Image3,'rb');
$data = fread($file,filesize($Image3));
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/html; 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: {$Image3_type};\n" .
" name=\"{$Image3_name}\"\n" .
//"Content-Disposition: attachment;\n" .//change to inline if you want.
//" filename=\"{$fileatt_name}\"\n" .
"Content-Transfer-Encoding: base64\n\n" .
$data . "\n\n" .
"--{$mime_boundary}--\n";
}
if (is_uploaded_file($Image4)) {
// Read the file to be attached ('rb' = read binary)
$file = fopen($Image4,'rb');
$data = fread($file,filesize($Image4));
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/html; 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: {$Image4_type};\n" .
" name=\"{$Image4_name}\"\n" .
//"Content-Disposition: attachment;\n" .//change to inline if you want.
//" filename=\"{$fileatt_name}\"\n" .
"Content-Transfer-Encoding: base64\n\n" .
$data . "\n\n" .
"--{$mime_boundary}--\n";
}
if (is_uploaded_file($Image5)) {
// Read the file to be attached ('rb' = read binary)
$file = fopen($Image5,'rb');
$data = fread($file,filesize($Image5));
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/html; 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: {$Image5_type};\n" .
" name=\"{$Image5_name}\"\n" .
//"Content-Disposition: attachment;\n" .//change to inline if you want.
//" filename=\"{$fileatt_name}\"\n" .
"Content-Transfer-Encoding: base64\n\n" .
$data . "\n\n" .
"--{$mime_boundary}--\n";
}
if (is_uploaded_file($Image6)) {
// Read the file to be attached ('rb' = read binary)
$file = fopen($Image6,'rb');
$data = fread($file,filesize($Image6));
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/html; 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: {$Image6_type};\n" .
" name=\"{$Image6_name}\"\n" .
//"Content-Disposition: attachment;\n" .//change to inline if you want.
//" filename=\"{$fileatt_name}\"\n" .
"Content-Transfer-Encoding: base64\n\n" .
$data . "\n\n" .
"--{$mime_boundary}--\n";
}
$message .= '<input type=submit Value="Add record to PROVIDER table"></form>';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

if( mail($to, $subject, $message, $headers) ) {
echo "<h1>Web Page Requested</h1>";
echo "<p>An email has been sent to the admin to verify the details you have posted.</p>";
echo "<p><b>Please allow 24 hours for it to be on the web site.</b></p>";
echo "<h1>Thank you!</h1>";
} else {
echo "<p>Error. Sorry the mail was not sent.</p>";
echo "<p>Send us an email at admin@scasp.org to let us know, thanks.</p>";
}
echo $message;

Thanks