ZIP file by byte [] in PHP

0

I want to send a zip file to a web service SOAP, to put it in the xml they ask me to transform it into an array of bytes. I have tried several things but, apparently, they do not work. In visual basic it can be like this:

Dim B() As Byte = IO.File.ReadAllBytes("")

In PHP there will be something similar?

    
asked by César Ravl Nolasco Huamanchumo 13.06.2017 в 01:10
source

2 answers

0

Generally a PHP String is compatible with an array byte in .NET.

$byteArr = file_get_contents('file.zip');

And you can send the variable byteArr to the web service although depending on the Web Service specification you probably have to code it before with Base64.

    
answered by 13.06.2017 в 01:39
0

Well, I managed to find out that this code in VB.NET

Dim b() As Byte
b = IO.File.ReadAllBytes("archivo.zip")

It is equivalent in PHP to

$handle = fopen("archivo.zip", "rb");
$contents = fread($handle, filesize("archivo.zip"));
fclose($handle);
$b= unpack("C*",$contents);

Thank you all for answering.

    
answered by 13.06.2017 в 02:07