【发布时间】:2012-11-02 14:51:38
【问题描述】:
我在 mysql blob 对象中存储一个 pdf 或文本文件,我正在尝试使用 php mailer 在邮件中将其作为附件发送。
我正在发送邮件。
$mail->AddAddress($pr_email);
$mail->Subject = "Meeting Invitation -$meeting_name";
$mail->AddStringAttachment($data);
$mail->IsHTML(true);
$mail->Body =$message;
if(!$mail->Send())
{
$message= "Error sending: " . $mail->ErrorInfo;
header("Location:userprofile.php?Message={$message}");
}
$data 来自哪里
$tmpName = $_FILES['image']['tmp_name'];
$fp = fopen($tmpName, 'r');
$data = fread($fp, filesize($tmpName));
$data = addslashes($data);
fclose($fp);
$query = "UPDATE demo_meeting SET attachment='$data' where meetingID='$mtngid'";
$results = mysql_query($query);
现在我以附件形式接收邮件,但内容不存在,只显示0K。
请告诉我我可能做错了什么。
【问题讨论】:
-
Please, don't use
mysql_*functions in new code。它们不再维护,deprecation process 已开始使用。看到red box?改为了解prepared statements,并使用PDO 或MySQLi - this article 将帮助您决定哪个。如果你选择 PDO,here is a good tutorial.