FLASH画的图片通过PHP发送到邮件设计方法

8 篇文章 0 订阅

      这两个月在写一个CMS系统,很久没上来写过东西了,前几天公司的项目中要写一个外围程序,现在做好了,上来发个思路。为自己作备忘记,也当为有相关需求的朋友作参考。

 

需求:FLASH画好一幅图片后,传给PHP,PHP把图片用发送到客户的邮箱中。

php服务端代码

<?php

$data=$GLOBALS['HTTP_RAW_POST_DATA'];
$img=new Image();
if ($data){
 
 $picurl=$img->createImage($data);
 if ($picurl){
  echo $picurl;
 }else {
  echo "error";
 }
}else {
 $pic=$_REQUEST['pic'];
 $fromemail=$_REQUEST['fromEmial'];
 $toemail=$_REQUEST['toEmail'];
 echo "you send a email form $fromemail to $toemail ,pic is $pic";
}

class Image{

 function createImage($data){
  $now = date("YmdHis");
  $path = "../upload/";
  if(!file_exists($path.$now.".png")){
          $fo = fopen($path.$now.".png","w");
          if(!fwrite($fo,$data)){
                  return false;
          }else{
                  return $now;
          }
  }
 }

}

?>

FLASH端部分代码如下

var bmpData:BitmapData = new BitmapData(mc.width/3,mc.height,false,0xff0000);
    var _Matrix:Matrix=new Matrix();
    _Matrix.translate(mc.width/3/2,mc.height/2);
    bmpData.draw(mc,_Matrix);
    //************用于测试*******************
    /*var map:Bitmap=new Bitmap(bmpData);
    map.x=100
    map.y=100
    map.alpha=0.6
    theStage.addChild(map);*/
    //******************************************

    request.url=String(data_xml.imgSave.emailBtn);
    request.method = URLRequestMethod.POST;

    var pngBytes:ByteArray = PNGEncoder.encode(bmpData);
    var sendImg_loader:URLLoader =new URLLoader();
    request.contentType = "application/octet-stream";
    request.data =pngBytes;
    sendImg_loader.addEventListener(Event.COMPLETE, sndImgComplete);
    sendImg_loader.addEventListener(IOErrorEvent.IO_ERROR, sndImgError);
    sendImg_loader.load(request);

 

这里上传不了附件,我会在下载中把附件发上去

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值