开发者

Read an image to a byte array using php

开发者 https://www.devze.com 2023-01-04 06:19 出处:网络
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 us

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.

thanks


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

0

精彩评论

暂无评论...
验证码 换一张
取 消