dpjr86761 2011-06-16 09:54
浏览 43
已采纳

使用PHP从闪存到电子邮件图像和文本

I'm having a bit of trouble combining two things, sending text variables from flash and an image from flash. Here's what I do to email the image:

private function emailImage(imageToSend:MovieClip):void {
            trace("Sending Email");
            var data1:BitmapData = new BitmapData(imageToSend.width, imageToSend.height); 
            data1.draw(imageToSend);

            var en:JPGEncoder = new JPGEncoder(80);
            var bArray:ByteArray=   en.encode(data1);

            var header:URLRequestHeader = new URLRequestHeader("Content-type", "application/octet-stream");

            var request:URLRequest = new URLRequest();
            request.requestHeaders.push(header);
            request.url = "http://192.168.1.117/mail.php";
            request.method = URLRequestMethod.POST;
            request.data = bArray;

            var loader:URLLoader = new URLLoader();
            loader.dataFormat = URLLoaderDataFormat.BINARY;
            loader.addEventListener(Event.COMPLETE, MailCompleteHandler);
            try
            {
                loader.load(request);
            }
            catch(error:Error)
            {
                trace("Unable to load URL");
            }
        }

And to email text variable I do this:

private function sendDataDB(Path:String) {
            var urlRequest:URLRequest = new URLRequest(Path);
            var loader:URLLoader = new URLLoader;
            urlRequest.method = URLRequestMethod.POST;
            var vars:URLVariables = new URLVariables;
            vars.cardID = cardID;
            vars.userName = userName;
            urlRequest.data = vars;
            loader.dataFormat = URLLoaderDataFormat.TEXT;
            loader.addEventListener(Event.COMPLETE,userDataStored);
            loader.load(urlRequest);
        }

But how do I do both, I want to send some text that would change for each user to be used as the body of the text and the email address but also send the picture to attach.

Thanks

EDIT: Would it work to append data to the end of the URL:

request.url = "http://192.168.1.117/mail.php";

Not sure how to go about this, the correct format for the URL or how to read it in on the PHP side.

  • 写回答

1条回答 默认 最新

  • dsl36367 2011-06-16 12:06
    关注

    Yes, the solution will be to send the variables as GET, along with the image as POST. Add the variables to the end of the URL, for example "http://192.168.1.117/mail.php?cardID=" + cardID + "&userName=" + userName.

    In your PHP file, you have a global $_GET variable, which will hold the variables passed via URL.

    $cardID = $_GET["cardID"];
    $userName = $_GET["userName"];
    

    If you need more detail, you can read this post: Sending byteArray and variables to server-side script at the same time.

    Hope this helps.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 数学的三元一次方程求解
  • ¥20 iqoo11 如何下载安装工程模式
  • ¥15 本题的答案是不是有问题
  • ¥15 关于#r语言#的问题:(svydesign)为什么在一个大的数据集中抽取了一个小数据集
  • ¥15 C++使用Gunplot
  • ¥15 这个电路是如何实现路灯控制器的,原理是什么,怎么求解灯亮起后熄灭的时间如图?
  • ¥15 matlab数字图像处理频率域滤波
  • ¥15 在abaqus做了二维正交切削模型,给刀具添加了超声振动条件后输出切削力为什么比普通切削增大这么多
  • ¥15 ELGamal和paillier计算效率谁快?
  • ¥15 蓝桥杯单片机第十三届第一场,整点继电器吸合,5s后断开出现了问题