*upload*

        **Key Arguments:**
            - ``imagePath`` -- path to the image to upload
            - ``title`` -- title of the image. Default **False** to just use filename
            - ``private`` -- is photo private?, Default **True**
            - ``tags`` -- a comma separated string. Default **False**
            - ``description`` -- the description for the image/photo. Default **False**
            - ``imageType`` -- image type. Default **photo** [photo|screengrab|image]
            - ``album`` -- add the photo to a specific album/photoset. If the album does not exist it will be created for you. Default *False*.
            - ``openInBrowser`` -- view the photo in flickr webapp once uploaded *Default: False*

        **Return:**
            - ``photoid`` -- the unique flickr-assigned ID of the uploaded image

        **Usage:**

            To upload an image to flickr from your local file-system, use the following:

            .. code-block:: python

                from picaxe import picaxe
                flickr = picaxe(
                    log=log,
                    settings=settings
                )
                photoid = flickr.upload(
                    imagePath="/path/to/image.png",
                    title="my lovely image",
                    private=False,
                    tags="lovely, icon",
                    description="this is a test image",
                    imageType="image",
                    album="my icons",
                    openInBrowser=True
                )
                print photoid

            This will upload an image to the "my icons" album (creating the album if it doens't exist yet) and open the image in the flickr web-app whenever upload is complete. Note title, description, tags and album are optional.

def upload(
            self,
            imagePath,
            title=False,
            private=True,
            tags=False,
            description=False,
            imageType="photo",
            album=False,
            openInBrowser=False):
        """*upload*

        **Key Arguments:**
            - ``imagePath`` -- path to the image to upload
            - ``title`` -- title of the image. Default **False** to just use filename
            - ``private`` -- is photo private?, Default **True**
            - ``tags`` -- a comma separated string. Default **False**
            - ``description`` -- the description for the image/photo. Default **False**
            - ``imageType`` -- image type. Default **photo** [photo|screengrab|image]
            - ``album`` -- add the photo to a specific album/photoset. If the album does not exist it will be created for you. Default *False*.
            - ``openInBrowser`` -- view the photo in flickr webapp once uploaded *Default: False*

        **Return:**
            - ``photoid`` -- the unique flickr-assigned ID of the uploaded image

        **Usage:**

            To upload an image to flickr from your local file-system, use the following:

            .. code-block:: python

                from picaxe import picaxe
                flickr = picaxe(
                    log=log,
                    settings=settings
                )
                photoid = flickr.upload(
                    imagePath="/path/to/image.png",
                    title="my lovely image",
                    private=False,
                    tags="lovely, icon",
                    description="this is a test image",
                    imageType="image",
                    album="my icons",
                    openInBrowser=True
                )
                print photoid

            This will upload an image to the "my icons" album (creating the album if it doens't exist yet) and open the image in the flickr web-app whenever upload is complete. Note title, description, tags and album are optional.

        """
        self.log.info('starting the ``upload`` method')

        basename = os.path.basename(imagePath)
        basename = os.path.splitext(basename)[0]

        if title == False or title == None:
            title = basename

        if private == True:
            is_public = 0
        else:
            is_public = 1

        if imageType == "image":
            content_type = 3
        elif imageType == "screengrab":
            content_type = 2
        else:
            content_type = 1

        if tags is not False and tags != None:
            tags = tags.replace(",", " ").replace("  ", " ")
        else:
            tags = ""

        if description == False or description == None:
            description = ""

        files = {
            'photo': (basename, open(imagePath))
        }

        params = {
            "title": title,
            "description": description,
            "tags": tags,
            "is_public": is_public,
            "content_type": content_type,
            "format": "json"
        }

        url = 'https://up.flickr.com/services/upload/'
        raw = requests.Request('POST', url, data=params, auth=self.auth)
        prepared = raw.prepare()
        headers = {'Authorization': prepared.headers.get('Authorization')}

        try:
            response = requests.post(
                url=url,
                data=params,
                headers=headers,
                files=files
            )
        except requests.exceptions.RequestException:
            print('HTTP Request failed')

        matchObject = re.search(
            r"<photoid>(\d*)</photoid>", response.content, re.S)
        photoid = matchObject.group(1)

        photoURL = "https://www.flickr.com/photos/" + \
            self.settings["flickr"]["user_nsid"] + "/" + photoid

        if album:
            self._add_photo_to_album(
                photoId=photoid,
                album=album
            )

        if openInBrowser:
            ## open in webbrowser
            import webbrowser
            webbrowser.open_new_tab(photoURL)

        self.log.info('completed the ``upload`` method')
        return photoid