Exemple #1
0
def upload_avatar():
    form = UploadAvatarForm()
    if form.validate_on_submit():
        image = form.image.data
        filename = avatars.save_avatar(image)  # 保存头像,并取得文件名
        current_user.avatar_raw = filename
        db.session.commit()
        flash('文件已上传。', 'info')
    flash_errors(form)
    return redirect(url_for('.change_avatar'))
Exemple #2
0
def upload_avatar():
    form = UploadAvatarForm()
    if form.validate_on_submit():
        image = form.image.data
        filename = avatars.save_avatar(image)
        current_user.avatar_raw = filename
        db.session.commit()
        flash('Image upload,please crop.', 'success')
    flash_errors(form)
    return redirect(url_for('user.change_avatar'))
Exemple #3
0
def upload_avatar():
	"""
	更新头像
	"""
	logger.info('url = ' + str(request.url))
	form = UploadAvatarForm()
	if form.validate_on_submit():
		image = form.image.data
		filename = avatars.save_avatar(image)
		# 更新头像
		current_user.avatar_raw = filename
		db.session.commit()
		flash('文件已上传,请裁剪!', 'success')
	flash_errors(form)
	return redirect(url_for('.change_avatar'))