我在我的Flask应用程序中使用Flask Uploads来进行上传表单。但是,每当我尝试保存文件时,就会出现以下错误:
File "/Users/Documents/virtual_environment/bin/../lib/python2.7/os.py", line 157, in makedirs
mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/app'
看起来上传没有必要的权限来保存文件?这是我使用flask-uploads的配置:
UPLOADS_DEFAULT_URL = os.environ.get("UPLOADS_URL", "http://localhost:5000/")
UPLOADS_DEFAULT_DEST = "/app/uploads/"
UPLOAD_EXTENSIONS = set(["csv", "xls", "xsls"])
此外,以下是我保存实际文件的方法:
@app.route('/upload', methods = ['GET', 'POST'])
@app.route('/upload/', methods = ['GET', 'POST'])
@roles_accepted('admin', 'team')
def r_upload():
form = FileUploadForm()
if form.validate_on_submit():
filename = uploadSet.save(form.uploadfile.data)
url = uploadSet.url(filename)
flash("%s uploaded <a href=\'%s\'>HERE</a>!" % (filename, url))
return render_template('/uploads.html',
dashboard_title = "%s Uploads" % g.name,
form = form)
错误是由于存储行引起的。您有什么修复建议吗?谢谢。
/app/uploads/
目录拥有文件权限?使用ls -la /app/uploads
命令来检查。 - Anshul Goyal