<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _upload_media(self,directory,files=None,resize_request=None, \ movealbum_request=None,changetitle_request=None):
 """Uploads media file to FB, returns True if uploaded successfully, Will replace if already uploaded, If megapixels > 0, will scale photos before upload If no filename given, will go through all files in DB"""

        # Connect if we aren't already
        if not self._connectToFB():
            logger.error("%s - Couldn't connect to fb")
            return False

        _megapixels=self._load_megapixels(directory)

        # Get an album ID (create album if not exists)
        _album_id,_album_name=self._get_album(directory)

        if not _megapixels:
            mpstring="original"
        else:
            mpstring=("%0.1f MP"%(_megapixels))

        # If no files given, use files from DB in dir
        if not files:
            db=self._loadDB(directory)
            files=db.keys()

        #If only one file given, make it a list
        if isinstance(files,basestring):
            files=[files]

        files.sort()

        for filename in files:

            # Get title here if any
            title=self._get_title(directory,filename)

            if title:
                print("%s - Uploading to fb, album[%s] size=%s title=%s"\
                        %(filename,_album_name,mpstring,title))
            else:
                print("%s - Uploading to fb, album[%s] size=%s"\
                        %(filename,_album_name,mpstring))

            status=self._upload_or_replace_fb(directory,filename, \
                    _album_id, _megapixels,resize_request,movealbum_request,\
                    changetitle_request,title)
            if not status:
                return False

        return True