Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/251.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在php中将图像转换为字节数组格式_Php_Image_Codeigniter_Bytearray_Soap Client - Fatal编程技术网

如何在php中将图像转换为字节数组格式

如何在php中将图像转换为字节数组格式,php,image,codeigniter,bytearray,soap-client,Php,Image,Codeigniter,Bytearray,Soap Client,我专注于建立一个新的项目,将搜索图像和显示结果。为此,我使用了一个使用SOAP客户端的.NETweb服务 但是在调用函数UploadFile()时,第一个参数是图像的字节数组格式,但每次它都显示null 我的代码如下 $client = new SoapClient("http://www.myserviceurl.com?wsdl"); $byte_array = file_get_contents('mypic.jpg'); $image = base64_encode($byt

我专注于建立一个新的项目,将搜索图像和显示结果。为此,我使用了一个使用SOAP客户端的
.NET
web服务

但是在调用函数
UploadFile()
时,第一个参数是图像的字节数组格式,但每次它都显示null

我的代码如下

  $client = new SoapClient("http://www.myserviceurl.com?wsdl");
  $byte_array = file_get_contents('mypic.jpg');
  $image = base64_encode($byte_array);
  $result=$client->Upload($image, "mypic.jpg");
  print_r($result);
但是,
$result
是这样打印的

stdClass Object ( [UploadFileResult] => Buffer cannot be null. Parameter name: buffer )
请告诉我如何获得上传图像的
bytearray
。。
提前谢谢

检查此项

<?php
$filename = "mypic.jpg";//Image path
$file = fopen($filename, "rb");
$contents = fread($file, filesize($filename));
fclose($file);
?>

快乐编码