A peer of mine is developing an iPhone application that will allow users to post images on my site via my API. I am building the part of the API that will accept and process the images.
The mobile developer is sending headers like such:
Content-Disposition: form-data; name="photo_1"; filename="photo_1.jpg"
Content-Type: application/octet-stream
When looking for the images sent, is it the same method as with normal HTML forms? Should I look for $_FILES?
Or, using PHP, how would I find his image?
Doesn't appear it's being sent via a form, i.e.,
<form enctype=multipart/form-data">
and<input type="file">
, so the$_FILES
array won't be populated.You'll probably need to read:
or do:
From the manual:
For more info, check out:
http://php.net/manual/en/wrappers.php.php
http://php.net/manual/en/reserved.variables.httprawpostdata.php
See these answers I gave to similar questions (processing uploads from
php://input
):I suppose iOS is sending the whole file as a single block of data in the POSTDATA section of the HTTP request. You can retrieve the whole POSTDATA (not parsed):
$_FILES
is meant for reading files sent withenctype="multipart/form-data"
in a proper HTML form. iOS is probably sending a plain old POST containing just a bunch of bytes which represent the file.Tell me if this solves!