dongping4901 2011-06-30 22: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 23: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条)

报告相同问题?

悬赏问题

  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 关于#python#的问题:自动化测试