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.