Three things:
When setting the
Content-Type
header, usesetValue:forHTTPHeaderField
rather thanaddValue:forHTTPHeaderField
.There's a superfluous CRLF for the image parameter:
This:
[postBody appendData:[@"Content-Disposition: form-data; name=\"image\"; filename=\"image.jpg\"\r\n\r\n" dataUsingEncoding:NSUTF8StringEncoding]];
should be
[postBody appendData:[@"Content-Disposition: form-data; name=\"image\"; filename=\"image.jpg\"\r\n" dataUsingEncoding:NSUTF8StringEncoding]];
Don't pass
nil
tosendSynchronousRequest:returningResponse:error
for either theresponse
orerror
parameters. Both of these will hold vital debugging information after the request has been made.
UPDATE: Your boundary ghkyre–nhjfhdj-74f5f-gfg5-gggff
contains a Unicode character –
. Replace it with -
and you can access the POST data via PHP.