The purpose of this gist is to point out that iPhone and Android HTTPClient handle HTTP requests differently when combining file uploads with other form data, for example uploading a photo along with a title or message.
The iOS implementation, as usual, is correct and handles this situation perfectly and as expected.
The Android implementation, on the other hand, doesn't seem to put together the MIME envelope correctly. Dumping the contents of both $_POST
and $_FILES
produce empty arrays, where both $_POST['title']
and $_FILES['file']
should exist, as they do in the iOS implementation. In short, the data never gets to the user's PHP script in a way that the user can use it effectively.
I have also dumped the contents of php://input
for examination. This is the RAW post body that remains when PHP can't decode the contents (commonly used for PUT requests with data)
I have filed a bug report on this issue with Appcelerator: https://jira.appcelerator.org/browse/TC-3082
In case someone lands on this Gist, to solve the issue simply leave out line 39 on app.js. Titanium takes care of the HTTP Headers automatically.