PLEASE HELP! I am totally at a loss here! I am new to PHP coding. I have a client that is requesting the ability to be able to send an attachment through an email form. I had this working on my website (through hosting company A) but on the clients website (hosting company it does not work. I get the data back form the basic form fields but not the attachment. We went through the process of turning register globals on (they are off) but that didn't resolve the problem. Is there any reason why this would work on one server and not another?
Below is my php code:
// Obtain file upload vars
$attachment_name = $FILES['fileatt']['name'];
$attachment = $FILES['fileatt']['tmp_name'];
$attachment_type = $FILES['fileatt']['type'];
$attachment_size = $FILES['fileatt']['size'];
$headers = "From: $from";
if (is_uploaded_file($attachment)) {
// Read the file to be attached ('rb' = read binary)
$file = fopen($attachment,'rb');
$data = fread($file,filesize($attachment));
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: {$attachment_type};\n" .
" name=\"{$attachment_name}\"\n" .
"Content-Transfer-Encoding: base64\n\n" .
$data . "\n\n" .
"--{$mime_boundary}--\n";
}
My HTML code is for the attachment field is:
<td><div align="right">Resume:</div></td>
<td><input type="file" name="fileatt" size="40">
Any help would greatly be appreciated as I have no clue what do anymore. I have exhausted all my options over the past month trying to figure this out.