我在下面的代码工作正常。它将数据发送到数据库,同时发送包含数据的电子邮件,但我无法弄清楚如何将图像作为附件。他们上传的数据库上有一个图像。
#include <iostream>
using namespace std;
int readNumber() {
cout << "Enter a number: ";
int x;
cin >> x;
return x;
}
void writeResult(int x) {
cout << "Sum of your numbers is " << x << endl;
}
最糟糕的部分
$query = "INSERT INTO postoffers(postedby,reqName,reqEmail,reqHotel,reqOutlet,reqCnum,reqPostType,reqPostHead,reqPostDet,offerStarts,offerEnds,file,type,size) VALUES('$cuser','$rname','$remail','$rhotel','$routlet','$rcnum','$rposttype','$rposthead','$rpostdet','$rbdate','$redate','$file','$file_type','$file_size')";
$res = mysql_query($query);
if ($res) {
$errTyp = "success";
$errMSG = "Successfully Posted!";
$to = $remail;
$subject = "Your Post Offer";
$message = "Hello <strong>" . $cuser . "</strong>,";
$message .= "<table width='600' border='0' cellspacing='10' cellpadding='0'>
<tbody>
<tr>
<td>This is a confirmation that you have posted a new offer for The Concierge App. Please kindly see the details below.</td>
</tr>
<tr><td>
<table width='600' border='1' cellspacing='0' cellpadding='10' bordercolorlight='#B4B1B1'>
<tbody>
<tr>
<td width='166'><strong>Requester Name :</strong></td>
<td width='374'>" . $rname . "</td>
</tr>
<tr>
<td width='166'><strong>Email :</strong></td>
<td width='374'>" . $remail . "</td>
</tr>
<td width='166'><strong>Hotel :</strong></td>
<td width='374'>" . $rhotel . "</td>
<tr>
<td width='166'><strong>Outlet Name/Spa Name :</strong></td>
<td width='374'>" . $routlet . "</td>
</tr>
<tr>
<td width='166'><strong>Contact Number :</strong></td>
<td width='374'>" . $rcnum . "</td>
</tr>
<tr>
<td width='166'><strong>Post Type :</strong></td>
<td width='374'>" . $rposttype . "</td>
</tr>
<tr>
<td width='166'><strong>Post Headline :</strong></td>
<td width='374'>" . $rposthead . "</td>
</tr>
<tr>
<td width='166'><strong>Post Details :</strong></td>
<td width='374'>" . $rpostdet . "</td>
</tr>
<tr>
<td width='166'><strong>Post Begin Date :</strong></td>
<td width='374'>" . $rbdate . "</td>
</tr>
<tr>
<td width='166'><strong>Post End Date :</strong></td>
<td width='374'>" . $redate . "</td>
</tr>
<tr>
<td width='166'><strong>Display Image :</strong></td>
<td width='374'>" . $file . "</td>
</tr>
</tbody>
</table>
</td></tr>
</tbody>
</table>";
$headers = 'From: AFPWebSpecialist@gmail.com' . "\r\n" .
$headers = "MIME-Version: 1.0" . "\r\n" .
$headers = "Content-type:text/html;charset=iso-8859-1" . "\r\n" .
'Reply-To: afpwebspecialist@gmail.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
一段代码显示图像的文件名。