前段
1 <form enctype="multipart/form-data"> 2 3 </form>
后端
1 @app.route(‘/upload‘, methods=[‘GET‘, ‘POST‘]) 2 def upload_file(): 3 if request.method == ‘POST‘: 4 f = request.files[‘filename‘] 5 f.save(‘/upload/1.txt‘) 6 # 访问文件属性 7 print(secure_filename(f.filename)) # Werkzeug提供方法,防止路径伪造