views:

70

answers:

1

Using php I need to read an image to a byte stream which has to be passed to a .NET web service. Can anyone provide me with a php code snippet to read an image to a byte array ? I am using using php 5.
thanks

+2  A: 

I don't believe PHP natively supports byte arrays in the same sense that .NET does. However, you could try converting each character to its ASCII representation:

<?
$file = file_get_contents($_FILES['userfile']['tmp_name']);
$byteArr = str_split($file);
foreach ($byteArr as $key=>$val) { $byteArr[$key] = ord($val); }
?>

Source: http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/Q_23325692.html

Colin O'Dell
Thanks! This code is quite sufficient for my purpose
chathuradd