Using php I need to read an image to a byte stream which has to be passed to a .NET web service. Can anyone provid开发者_开发问答e me with a php code snippet to read an image to a byte array ? I am using using php 5.
thanksI 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
精彩评论