页面:

html内容:
{% for messages in get_flashed_messages() %}
{{ messages }}
{% endfor %}
WW打补丁操作
服务端内容:
@ww.route('/upload',methods=['POST','GET'])
def upload():
if request.method == 'POST':
file = request.files['file']
if file and allww_file(file.filename):
upload_path = app.config['UPLOAD_FOLDER']
if not os.path.exists(upload_path):
os.mkdir(upload_path)
upload_file = path.join(upload_path,secure_filename(file.filename))
file.save(upload_file)
flash('upload file %s complete!' %file.filename)
return redirect(url_for('ww.upload'))
else:
flash('nothin file select or file type error!')
return render_template('ww/patchww.html')
@ww.route('/Patchww',methods=['GET','POST'])
def Patchww():
cmdpatch = None
serverlists = wwGame.query.all()
patchform = PatchCommandForm()
if patchform.validate_on_submit():
session['cmdpatch'] = patchform.patchcommand.data
session['serverID'] = request.form.getlist('dbcheckbox')
#判断是否选服
if session.get('serverID') == []:
flash(u'未选游戏服,请勾选游戏服!')
return redirect(url_for('ww.Patchww'))
for db in session.get('serverID'):
dbsql = wwGame.query.filter_by(serverId=db).first()
dbhost = dbsql.serverHost
dbname = dbsql.serverName
session['dbname'] = dbname
session['dbhost'] =dbhost
print session.get('dbhost')
print session.get('cmdpatch')
return redirect(url_for('ww.Patchww'))
return render_template('ww/patchww.html',
serverlists=serverlists,
patchform=patchform,
)
当使用第二个form时,也就是上传文件的时候:

出现了:'patchform' is undefined
但是 patchform 是第一个form的定义内容。这为咋提交的时候会触发第一个from 的?
===================
form1,form2其实对应了两个后端的views,当form2的views上传完文件后,form1的views里要怎样获得刚刚上传的文件的文件名?
即:
@ww.route('/Patchww',methods=['GET','POST']) 要怎样取到@ww.route('/upload',methods=['POST','GET'])这里面的file.filename值?
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
Ajax提交到不同链接不就好了