I've searched around but I think my problem is a little too specific to find a good answer without posting.
I've been working on an API to prepare my site to be used by a mobile app. An API is new territory for me, so I used a PHP MVC API tutorial that I found (link: http :// net.tutsplus.com/ tutorials/ php/ creating-an-api-centric-web-application/ ) to start it off. I've removed all the inapplicable elements and have been able to successfully customize it for my own needs. Adapting the tutorial in to something useful for me has been easy.
What isn't covered in this tutorial however, and what I unfortunately can not seem to figure out, is how a file can be posted to this type of API. I need the API to be able to accept image files along with the user's description of the image.
Details on the API set up:
The client side takes an app public key, an app private key, the user's credentials, a controller name, an action name and a set of parameters for the action. It encrypts the whole request in to one string using mcrypt and the app's private key. It then POSTs to the api url two things: the public key and the encrypted request.
The API itself then reconciles the public key with it's private key on it's side, decrypts the encoded request using the apps stored private key, and if its decrypted succesfully begins taking the actions described in the request.
Like I said, this is all been easy for me to use and customize when I only need it to work with JSON objects, but I am at a loss as to how to adjust this system to enable a file upload via the same process. Should the client side convert this to text, encrypt it and post it the same way? Or should the api itself accept file uploads via $_FILES?
I have been stuck at this point. So any insight by anyone would be helpful. I will do my best to answer any questions you have.