Jump to content

FILE UPLOAD and SEND as MAIL attachement problem


php1

Recommended Posts

Hi all,

I have to upload one resume and send it as mail as an attachemnt using php.

My problem is that when  I open my mail mail box i got the attachment.

 

But i am able to view only contents of some attachment. the others are blank.

but the size of the attachment is there. only the contents are not displayed for some attachment. anybody please help.

 

I have pasted the code below: upload.php file is this .

 

<?php

ob_start();

$strBody = "<html><body> <table width='500' border='0' bgcolor='#EAEAEA' bordercolor='#d2c9b2' align='center' style='font-family:Tahoma; font-size:11px; color:#3C3C3C;'><tr><td colspan='2' align='center' cellpading='10'><h5><b>" . 'New Candidate Resume Details' . "</b></h5></td></tr><tr><td width='25%'>" . 'Name        ' . "</td><td>" . @$_POST["name"] . "</td></tr><tr><td>". 'Email    ' . "</td><td>" . $_POST["email"] . "</td></tr><tr><td>". 'Mobile    ' . "</td><td>" . $_POST["mobile"] . "</td></tr><tr><td>". 'Description    ' . "</td><td>" . $_POST["description"] . "</td></tr></table></body></html>";

$subject="Enquiry ";

$name=$_POST['name'];

$email=$_POST['email'];

$to="[email protected]";

$from = stripslashes($name)."<".stripslashes($email).">";

$mime_boundary="==Multipart_Boundary_x".md5(mt_rand())."x";

$tmp_name = $_FILES['file']['tmp_name'];

$type = $_FILES['file']['type'];

$name = $_FILES['file']['name'];

$size = $_FILES['file']['size'];

if(file_exists($tmp_name))

{

if(is_uploaded_file($tmp_name))

{

$file = fopen($tmp_name,'rb');

$data = fread($file,filesize($tmp_name));

fclose($file);

$data = chunk_split(base64_encode($data));

}

$headers = "From: $from\r\n" .

"MIME-Version: 1.0\r\n" .

"Content-Type: multipart/mixed;\r\n" .

" boundary=\"{$mime_boundary}\"";

$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" .

$strBody . "\n\n";

$message .= "--{$mime_boundary}\n" .

"Content-Type: {$type};\n" .

" name=\"{$name}\"\n" .

"Content-Transfer-Encoding: base64\n\n" .

$data . "\n\n" .$size.

"--{$mime_boundary}--\n";

mail($to, $subject, $message, $headers);

header ("Location: thanks.htm");

}

ob_flush();

?>

 

the POSt values are coming from anotherpage.

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.