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

    希望能解决您的问题。

    如果有用请点个赞吧!

  • 相关阅读:
    Python import模块
    Python 内置函数
    Python Pickle序列化
    android xml布局文件属性说明
    android 中动画
    Android样式——Styles
    代码家
    Android UI目录
    Android 基本控件
    android and webview 网页应用
  • 原文地址:https://www.cnblogs.com/perl2py/p/6559063.html
Copyright © 2011-2022 走看看