var account = document.getElementById('account').value
var file = document.getElementById('file').files[0]
var data = new FormData()
data.append('file',file,file.name)
data.append('account',account)
axios({
method: 'post',
url: '/back/index',
headers: {'Content-Type': 'multipart/form-data'},
onUploadProgress: function (progressEvent) {
console.log(progressEvent)
},
data: data
})
.then(function (ret) {
console.log(ret.data)
})
.catch(function (err) {
console.log(err)
})
@app.route('/back/index', methods=['POST', 'GET'])
def backIndex():
if request.method == 'POST':
file = request.files['file']
filename = request.files['file'].filename
getData = request.form['account']
print(getData)
print(file)
return jsonify({'code':200,'msg': 'such'})
return render_template('back/index.html')
最后編輯于 :
?著作權歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者