符合条件的纪录以附件形式发送,该如何处理? 附件实际上是一个mime段不知道你是怎么发送已存在的文件的,不过道理是一样的 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 就是先从数据库里把符合条件的纪录选择出来,是不是需要生成一个文件?然后再作为附件发送?我以前用的下载程序,只需要文件头加上Header("Content-disposition: attachment; filename=support.csv");Header("Content-type: application/octet-stream; name=support.csv");这两句话,就可以下载下来了,这时候可以添加条件进行查询,按照常规的打印语句,就把文件以csv格式下载下来了。我现在有的一个发附件的函数程序,它是需要已经存在的文件作为附件才可以,所以我的这种情况就不知道怎么处理了。http://community.csdn.net/Expert/topic/3186/3186904.xml?temp=.9640924 那个发附件的程序因该有直接写str的方法的,没有的话也可以改一下啊从数据库读取出来以后如果可以直接写str的话就不用另外生成文件了 第一次涉及到传附件,好多我不太明白,讀出來的數據是几十条數據,不生成文件的话,我怎么能最为附件上传呢?现在这个传附件的也是以文件形式的,我贴出来麻烦你再指点一下,谢谢!function mail2( $to, $subject, $message, $from, $content_type, $attache="") { if(!empty($from)) $head = "From: $from\n"; if(empty($content_type)) $content_type = "text/plain"; if(is_array($attache)) { $boundary = "===" . md5(uniqid("")) . "==="; $head .= "Mime-Version: 1.0\nContent-Type: multipart/mixed; boundary=\""; $head .= "$boundary\"\n\nThis is a multi-part message in MIME format.\n\n"; $head .= "--$boundary\n"; $head .= "Content-Type: $content_type\n"; $head .= "\n$message\n\n"; while(list($key, $val) = each($attache)) { $fd = fopen("$val", "r") or die("unable to open file $val"); $contents = chunk_split(base64_encode(fread($fd,filesize("$val")))); fclose($fd); $head .= "--$boundary\n"; $head .= "Content-Type: application/octet-stream; name=\"".basename($val); //$head .= "Content-Type: application/octet-stream; name=support.csv; $head .= "\"\nContent-Transfer-Encoding: BASE64\n"; $head .= "Content-Disposition: attachment; filename=\"".basename($val); $head .= "\"\n\n" . $contents . "\n\n"; } $head .= "--" . $boundary . "--\n\n"; }else{ if(!empty($content_type)) { $head .= "Content-Type: $content_type\n"; $head .= "\n$message\n"; } } return mail($to,$subject,"",$head );}mail2("$send_to","",$message,"","",array("support.csv")); $fd = fopen("$val", "r") or die("unable to open file $val");$contents = chunk_split(base64_encode(fread($fd,filesize("$val"))));这里把fread换成你的字符串就可以了 请问分号和变量连接是什么意思? php中大家通常都用什么方法屏蔽错误信息? 下拉列表问题 PHP连接MSSQL的问题 php5 SESSION问题 在线等 如何启用COM? ______+ 如何生成静态页面??? php cookie设置的概念问题 用copy()上传好像限制了上传文件的大小,如何解除这个限制?? 请问如何将数组扩展 大家帮个忙,怎样在mysql数据库查询一个字段 6位QQ靓号免费送,经公证处认证!
我以前用的下载程序,只需要文件头加上
Header("Content-disposition: attachment; filename=support.csv");
Header("Content-type: application/octet-stream; name=support.csv");
这两句话,就可以下载下来了,这时候可以添加条件进行查询,按照常规的打印语句,就把文件以csv格式下载下来了。
我现在有的一个发附件的函数程序,它是需要已经存在的文件作为附件才可以,所以我的这种情况就不知道怎么处理了。
http://community.csdn.net/Expert/topic/3186/3186904.xml?temp=.9640924
function mail2( $to, $subject, $message, $from, $content_type, $attache="") {
if(!empty($from)) $head = "From: $from\n";
if(empty($content_type)) $content_type = "text/plain"; if(is_array($attache)) {
$boundary = "===" . md5(uniqid("")) . "===";
$head .= "Mime-Version: 1.0\nContent-Type: multipart/mixed; boundary=\"";
$head .= "$boundary\"\n\nThis is a multi-part message in MIME format.\n\n";
$head .= "--$boundary\n";
$head .= "Content-Type: $content_type\n";
$head .= "\n$message\n\n"; while(list($key, $val) = each($attache)) {
$fd = fopen("$val", "r") or die("unable to open file $val");
$contents = chunk_split(base64_encode(fread($fd,filesize("$val"))));
fclose($fd);
$head .= "--$boundary\n";
$head .= "Content-Type: application/octet-stream; name=\"".basename($val);
//$head .= "Content-Type: application/octet-stream; name=support.csv;
$head .= "\"\nContent-Transfer-Encoding: BASE64\n";
$head .= "Content-Disposition: attachment; filename=\"".basename($val);
$head .= "\"\n\n" . $contents . "\n\n";
}
$head .= "--" . $boundary . "--\n\n";
}else{
if(!empty($content_type)) {
$head .= "Content-Type: $content_type\n";
$head .= "\n$message\n";
}
}
return mail($to,$subject,"",$head );
}mail2("$send_to","",$message,"","",array("support.csv"));
$contents = chunk_split(base64_encode(fread($fd,filesize("$val"))));
这里把fread换成你的字符串就可以了