php1 Posted August 4, 2008 Share Posted August 4, 2008 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. Link to comment https://forums.phpfreaks.com/topic/118041-file-upload-and-send-as-mail-attachement-problem/ Share on other sites More sharing options...
php1 Posted August 4, 2008 Author Share Posted August 4, 2008 i have problem with file of type application/octent-stream, text/css etc Link to comment https://forums.phpfreaks.com/topic/118041-file-upload-and-send-as-mail-attachement-problem/#findComment-607348 Share on other sites More sharing options...
php1 Posted August 6, 2008 Author Share Posted August 6, 2008 there is no problem with msword file type. is thre any particular type we can check for resume other than doc type. how is type checking done for an uploaded file Link to comment https://forums.phpfreaks.com/topic/118041-file-upload-and-send-as-mail-attachement-problem/#findComment-609527 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.