Update database while uploading photo

When user uploads a new photo, the database and session variables will
be updated automatically.