dongping4901 2011-06-30 14:10
浏览 27
已采纳

有没有办法通过Flex的HttpService接收图像文件?

I've written this piece of code to use a PHP script to send data to Flex.

Here's the Flex Code:

<s:HTTPService id="imageService" url="http://localhost/bookView/amfphp/services/ImageServer/showImage.php" 
                   useProxy="false" 
                   method="POST"
                   result="handleImageResult(event)" 
                   fault="handleFault(event)" 
                   showBusyCursor="true">
        <s:request xmlns="">
            <bdla>"lashf"</bdla>
        </s:request>
    </s:HTTPService>

Here's the PHP code:

        public function returnRandomImage(){
            $contents = file_get_contents("images/code_complete2.png");
            header('Content-Type: image/png');

            return $contents;
        }

Thing is: I'm really interested in using PHP to send an image file, so that I could render it and use it in Flex. However, when I .send() this HttpService, all I get is a fault event with this message: (I've tried both with the header() function and without it).

(mx.messaging.messages::AcknowledgeMessage)#0
 body = "PNG"

That's it. Hope someone can help. If there is no way to use HttpService for this end (i.e. send image files), how can one do it then? I've seen it in an app I worked on so I'm positive it can be done.

EDIT Added PHP code too.

  • 写回答

2条回答 默认 最新

  • dongou5100 2011-06-30 15:34
    关注

    You can encode the image using Base64, this way you can send it and receive it as text.

    http://www.google.es/search?sourceid=chrome&ie=UTF-8&q=as3+base64+encoder

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部