I am sending email with attachments.. but I did not getting any extention in the email.. all the attachments having name noname without extention, if I attach mutiple files then the attachmment also have only one file named noname without extention too..


$strTo = $_POST["email"];
$strSubject = stripslashes($_POST["subject"]);
$strMessage = stripslashes($_POST["message"]);
$from = '******@gmail.com'; 
//*** Uniq id Session ***//
$strSid = md5(uniqid(time()));

$strHeader = "";
$strHeader .= "From: $from\r\n" . "MIME-Version: 1.0\r\n" . "Content-Type: multipart/mixed;\r\n"; 
$strHeader .= "Cc: {$_POST['cc']}\r\n";
$strHeader .= "Bcc: {$_POST['bcc']}\r\n";

$strHeader .= "MIME-Version: 1.0\n";
$strHeader .= "Content-Type: multipart/mixed; boundary=\"".$strSid."\"\n\n";
$strHeader .= "This is a multi-part message in MIME format.\n";

$strHeader .= "--".$strSid."\n";
$strHeader .= 'Content-Type: text/html; charset=iso-8859-1'.$eol;
$strHeader .= "Content-Transfer-Encoding: 7bit\n\n";
$strHeader .= $strMessage."\n\n";

//*** Attachment ***//
if($_FILES["fileAttach"]["name"][$i] != "")
$strFilesName = $_FILES["fileAttach"]["name"][$i];
$strContent = chunk_split(base64_encode(file_get_contents($_FILES["fileAttach"]["tmp_name"][$i])));
$strHeader .= "--".$strSid."\n";
$strHeader .= "Content-Type: application/octet-stream; name=\"".$strFilesName."\"\n";
$strHeader .= "Content-Transfer-Encoding: base64\n";
$strHeader .= "Content-Disposition: attachment; filename=\"".$strFilesName."\"\n\n";
$strHeader .= $strContent."\n\n";

$flgSend = @mail($strTo,$strSubject,null,$strHeader); // @ = No Show Error //

    header("Location: ".$_SERVER['PHP_SELF']."?id=".$_REQUEST['id']."&msg=Message Send"); 
    header("Location: ".$_SERVER['PHP_SELF']."?id=".$_REQUEST['id']."&msg=Message Not Send"); 

I got the below code from the web..

Member Avatar

I got the below code from the web..

OK, did you find answer to it? It would be nice if you can explain how you solve it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.