Search code examples
phpjavascriptandroidcordovaphoto-upload

Workflow for photo upload with login and photo display online


Hello I am working on an educational app just for my own learning where a user can login, upload photos, and then have them display on a website. I am a little confused on the general idea of how it should work. I know this isn't the best place for this type of question but I can't find it anywhere else.

Basically I want a user to be able to login with something like OpenID and then upload a photo ( I am using phonegap and thus they would use the Phonegap API to do this and I understand the mobile side here ) to a server and then have be hosted on the server and be able to have a user's photos displayed together.

Do I need to have each photo be submitted to a database and if so how would I store the photo info? If you have any input it would be appreciated I am a little lost. I know php for the server side I just don't know what to do.


Solution

  • Do I need to have each photo be submitted to a database

    Only if you want to, you would have the base64 encode it or store it as a blob though. Your best bet would be to store the image somewhere on your server outside of the database and instead store its address or path in a database along with a unique ID.

    how would I store the photo info?

    What photo info, the exif data? Or are you talking about additional general information? (date it was uploaded, user that uploaded it, etc etc) Either way, you would make a column in the database table for each chunk of data you want to store.

    For example, if you wanted to store the date each photo was uploaded and which user uploaded it, you would set up columns in such a way that a row in the database that look something like this:

    (columns)   id    photo               user         date 
    (row)       58    uploads/img58.jpg   myuser192    1338483324
    

    as for actually getting the photos on your server, perhaps you could use an html5 friendly solution like Uploadify