在浏览器中输入时,出现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')
希望能解决您的问题。
如果有用请点个赞吧!