I have rather complicated situation. I've previosly created some questions but now I'm closer to solution. Situation: Java coder sends me a request with picture. Here I receive his request and put it into log file:
$query = fopen("php://input",'rb');
$queryFile= fopen("/var/www/9292/querylog.txt","wb");
stream_copy_to_stream($query, $queryFile);
fclose($queryFile);
fclose($query);
Data from log is hexdecimal, so I handle it this way:
$query=file_get_contents("/var/www/9292/querylog.txt");
$query = preg_replace('/[\s
]+/', '', $query);
$queryHex=pack("H*", $query);
$inputImage=$queryHex;
$inputImage=trim($inputImage);
I don't know if I need to remove blanks, but removing and adding doesn't make changes in result. Then I create Image.
$imageFile=fopen("/var/www/9292/inputPhoto.jpg", 'wb');
fwrite($imageFile, $inputImage);
fclose($imageFile);
So, the problem: when Java coder sends a request, created picture is half-size and unreadable, but when I put data from log into Advanced Rest Client and use the same script it creates fine photo. I've got tcpdump oh his request. Here it is and it something like:
......JFIF.....`.`.....C......
..
......(.....1#%.(:3=<9387@H\N@DWE78PmQW_bghg>Mqypdx\egc...C......./../cB8Bcccccccccccccccccccccccccccccccccccccccccccccccccc........p.."......................................6......................!..1.A."Qa2q...B....#4Ccr......................................................A.1............?..j*i.}.+vE..s...d85..5.....K..`..hc..y..=@.3.|N.<...?.......h....Y.$.5....W%....?E..cm0..$.$...I$...s...... Z.P2.3.j9..I..w\..F.......1.c.{.?\~..>.m4.......E......{.).nm"B.|....u..........[.H..>..4.~...k.pl......KO..;z/K..S4./.6i.....OpEc...'.m..0k9Y.r.......e. n........>...8.........~.X.R...h...f.."...q...../..mmn.<..\NI?2..q...O.2nd!......A=...\7.qZ.YS..,.+q.....
(I don't show whole photo because of privacy=)). Now when I check a script with Advanced Rest Client and put there picture in binary it: 1. Puts data into log in binary format 2. Creates the same picture like Java coder request does.
So as I understand I should handle request in some other way. So, how can I handle it to get fine picture?