zoukankan      html  css  js  c++  java
  • windows python flask上传文件出现IOError: [Errno 13] Permission denied: 'E:\git\test\static\uploads'的解决方法

    在浏览器中输入时,出现IOError: [Errno 13] Permission denied: 'E:\git\test\static\uploads'

    http://127.0.0.1:5000/upload

    有如下俩种解决方法

    1. 第一种

     1 @app.route('/upload',methods=['GET','POST'])
     2 def upload():
     3     if request.method=='POST':
     4         f = request.files['file']
     5         basepath = path.abspath(path.dirname(__file__))
     6         filename = secure_filename(f.filename)
     7         upload_path=path.join(basepath,'static','uploads',filename)
     8         f.save(upload_path)
     9         return redirect(url_for('upload'))
    10      return render_template('upload.html')

    2. 第二种

    1 @app.route('/upload',methods=['GET','POST'])
    2 def upload():
    3     if request.method=='POST':
    4         f = request.files['file']
    5         filename = secure_filename(f.filename)
    6         f.save(path.join('static/uploads',filename))
    7         return redirect(url_for('upload'))
    8     return render_template('upload.html')

    希望能解决您的问题。

    如果有用请点个赞吧!

  • 相关阅读:
    HNOI 2006 BZOJ 1195 最短母串
    BZOJ 3029 守卫者的挑战
    Codeforces 401D Roman and Numbers
    ZJOI2010 数字计数
    BZOJ 3329 Xorequ
    Codeforces 235 C
    SPOJ 8222 Substrings
    BZOJ 1396 识别子串
    (模板)归并排序
    poj3122 Pie (二分)
  • 原文地址:https://www.cnblogs.com/perl2py/p/6559063.html
Copyright © 2011-2022 走看看