I need help, I can upload and store data into a mysql database. I can display it fine on an html rendered page, but I can not pull an image out of the database and send as an attachment in my email script. Here is the code:
while ($row = mysql_fetch_array($result))
{
$file = $row['img'];
$type = $row['img_type'];
$file_name = $row['img_name'];
$file_id = $row['img_id'];
}
function sendmsg($to, $subject, $text, $cc, $from, $file, $type, $file_name); {
$content = stripslashes(fread(fopen($file,"r"),filesize($file)));
$content = chunk_split(base64_encode($content));
$uid = strtoupper(md5(uniqid(time())));
$to = stripslashes($to);
$from = stripslashes($from);
$from2 = stripslashes($from2);
$cc = stripslashes($cc);
$subject = stripslashes($subject);
$text = stripslashes($text);
$header = "From: $from\nReply-To: $from\n";
$header .= "Return-Path: [email]email@address.com[/email]\n";
$header .= "Return-Receipt-To: [email]email@address.com[/email]\n";
$header .= "MIME-Version: 1.0\n";
$header .= "Content-Type: multipart/mixed; boundary=$uid\n";
$header .= "--$uid\n";
$header .= "Content-Type: text/plain\n";
$header .= "Content-Transfer-Encoding: 8bnoit\n\n";
$header .= "$text\n";
$header .= "\n";
$header .= "\n";
$header .= "--$uid\n";
$header .= "Content-Type: $type; name=\"$file_name\"\n";
$header .= "Content-Transfer-Encoding: base64\n";
$header .= "Content-Disposition: attachment; filename=\"$file_name\"\n\n";
$header .= "$content\n";
$header .= "--$uid--";
mail($to, $subject, "$text", $header);
return true;
}
sendmsg($to, $subject, $text, $cc, $from, $file, $file_type, $file_name);
I get this error:
Warning: fopen(FWS.É): failed to open stream: No such file or directory in
Thanks!!!