I’m programming an API of sorts on a PHP website I built with the goal that another programmer can send data (POST and FILES date) to my PHP website from their iPhone app so that I can process the data and return some of my own.
We’ve been struggling to find a way that he can send POST data (though we found a pretty hacky workaround) and FILES data from the iPhone app. The goal on my end would be to receive a POST array and a FILES array similar to (in PHP of course):
$_POST = array(
'key' => 'key-value-here',
'token' => 'token-value-here',
'id' => 'id-value-here'
'values' => array(
'name' => 'Name value here',
'description' => 'Description value here'
)
);
$_FILES = array(
'photo' => array(
'name' => 'photo-name.jpg',
'type' => 'image/jpeg',
'tmp_name' => '/tmp/path',
'error' => '0',
'size' => '12345'
)
);
Any help you could offer us on how we could send such data would be greatly appreciated. Also, the iPhone app programmer is trying to avoid using the ASIHTTPRequest library for now (for a number of reasons).
Just create a multi-part post. For how it should look like, see a multi-part message. I have never worked with the iPhone, so I couldn’t tell you which library could do this, but if all else fails, it’s just an open socket connection & some string manipulation…