• Flask 上传文件 IO错误


     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()

  • 相关阅读:
    php算法之选择排序
    php算法之插入排序
    五分钟读懂UML类图
    ZC_知识点
    JNI_C#
    JNI_Z
    20160419__第1课_第6课
    Hibernate异常_01
    ZC_注意点
    ZC_知识点
  • 原文地址:https://www.cnblogs.com/qqzj/p/5962823.html
Copyright © 2020-2023  润新知