예제 #1
0
def upload_avatar(name=None):
    """
    """
    extension = get_extension(name)
    up = UploadAvatar()
    path_image = up.ajax_upload(UP_AVATARS_TMP_FOLDER, extension)
    if up.allowed_file() == False:
        success = False
        message = g.users_msg("error_upload_1")
    else:
        up.thumb(AVATAR_IMAGE_SIZE["large"], os.path.join(UP_AVATARS_TMP_FOLDER, path_image))
        if path_image:
            success = True
            message = path_image
    if success:
        return dict(success=True, message=message)
    return dict(success=False, errors=[{"message": message}])
예제 #2
0
def upload_avatar(name=None):
    """
    """
    extension = get_extension(name)
    up = UploadAvatar()
    path_image = up.ajax_upload(UP_AVATARS_TMP_FOLDER, extension)
    if up.allowed_file() == False:
        success = False
        message = g.users_msg('error_upload_1')
    else:
        up.thumb(AVATAR_IMAGE_SIZE['large'],
                 os.path.join(UP_AVATARS_TMP_FOLDER, path_image))
        if path_image:
            success = True
            message = path_image
    if success:
        return dict(success=True, message=message)
    return dict(success=False, errors=[{"message": message}])
예제 #3
0
 def allowed_file(self):
     """ """
     self.extension = get_extension(self.filename)
     return '.' in self.filename and self.extension in ALLOWED_EXTENSIONS
예제 #4
0
파일: upload.py 프로젝트: imfht/flaskapps
 def allowed_file(self):
     """ """
     self.extension = get_extension(self.filename)
     return '.' in self.filename and self.extension in ALLOWED_EXTENSIONS