My webserver is receiving image data from an iOS App via HTTP POST.
The transmitted image-data looks like this:
$postvar1=x&image=<89504e47 0d0a1a0a 0000000d 49484452 00000100 00000064 08060000 006960ee 9e000020 00494441 547801ed 5d099c14 c5b9afea 9ed9fb98 5941c428 a2c62320 0a开发者_开发问答8a8047 3cf06017 573cc178 c0eea246 8db9f4f9 e22f79fa 7c26e6c5 f78cd1e4 19351ad9 5d0ea360 3c815d62 bc350a51 f008781b 82181570 67f66477
I don't know what to do with this string in PHP. What kind of encoding is it? Thanks!
Its a PNG file.
The PNG Magic number is 8950.4e47.0d0a.1a0a
ASCI \x89PNG\r\n\x1a\n
It's binary, it's an image file, it can't "Do" anything with it as it is...
And according to my hex editor, it's a PNG...
Since the other answers miss it: It what you get from -[NSData description] (a hexdump between angle brackets, like <01234567 89ABCDEF>
). This probably happens due to someone doing something like [NSString stringWithFormat:@"blah&image=%@", data]
. The reasons why this is terrible are too numerous to mention.
It's far, far preferable to upload as multipart/form-data or (if you send any other fields you need in a header) just image/png or application/octet-stream. The hexdump overhead is huge.
It's a png here is it
http://i.stack.imgur.com/bUXLb.png
256x100 but it's just transparent
If you want to convert it in php have a look at the pack function
精彩评论