Re: [问题] python 档案上传

楼主: gn00618777 (非常念旧)   2015-01-21 13:47:33
upload.html:
<html>
<body>
<form action=upload_file_form method="post">
<input type="file" name="file"></br>
<input type="submit" value="Send">
</form>
</body>
</html>
主程式.py:
UPLOAD_FOLDER='/home/bernie/flask_web_demaon/ovpn_files'
@app.route("/upload_file_form",methods=['GET','POST'])
def upload_file_form():
import os
file = request.files['file']
filename = secure_filename(file.filename)
file.save(os.path.join(app.config['UPLOAD_FOLDER'],filename))
return send_from_directory('static/report/flexmonkey/html','upload.html'
就可以了,谢谢。

Links booklink

Contact Us: admin [ a t ] ucptt.com