码迷,mamicode.com
首页 > Web开发 > 详细

Flask 上传文件 IO错误

时间:2016-10-15 11:31:41      阅读:147      评论:0      收藏:0      [点我收藏+]

标签:

 1 # -*- coding:utf-8 -*-
 2 from flask import Flask,request,render_template,redirect,url_for
 3 from os import path
 4 from werkzeug.utils import secure_filename
 5  
 6 app = Flask(__name__)
 7 
 8 @app.route(/upload,methods=[GET,POST])
 9 def upload():
10     if request.method==POST:
11         f = request.files[file]
12         basepath = path.abspath(path.dirname(__file__))
13         upload_path = path.join(basepath,static/uploads)
14         f.save(path.join(upload_path,secure_filename(f.filename)))
15         return redirect(url_for(upload))
16     return render_template(upload.html)
17  
18 if __name__ == __main__:
19     app.run(debug=True)

14行中加入path.join()

 

Flask 上传文件 IO错误

标签:

原文地址:http://www.cnblogs.com/qqzj/p/5962823.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!