烧瓶图像上传在服务器上不起作用,显示权限问题

时间:2018-10-20 12:11:26

标签: python-3.x flask flask-uploads

我正在尝试使用flask上传来上传图像,但未上传(python 3.6),我也将www-data用户和组分配给了静态文件夹,并且还授予了777权限,但仍然无法正常工作:< / p>

photos = UploadSet('photos', IMAGES)
app.config['UPLOADED_PHOTOS_DEST'] = '/static/'
configure_uploads(app, photos)

错误: File "/var/www/html/eiapp/eiapp/__init__.py", line 94, in upload photos.save(file) File "/usr/local/lib/python3.6/dist-packages/flask_uploads.py", line 422, in save, referer: http://142.93.212.243/eiapp/uploadform os.makedirs(target_folder), referer: http://142.93.212.243/eiapp/uploadform File "/usr/lib/python3.6/os.py", line 220, in makedirs, referer: http://142.93.212.243/eiapp/uploadform mkdir(name, mode), referer: http://142.93.212.243/eiapp/uploadform PermissionError: [Errno 13] Permission denied: '/static/', referer: http://142.93.212.243/eiapp/uploadform

@app.route('/uploadform')
def upload_file_form():
    return render_template('upload.html')

@app.route('/upload',methods=['POST','GET'])
def upload():
if request.method=='POST' and 'file' in request.files:
    file=request.files['file']
    filename = secure_filename(file.filename)
    photos.save(file)
    return 'uploaded'

.conf文件::

<VirtualHost *:80>
            ServerName 142.93.212.243
            ServerAdmin ei.com@gmail.com
            WSGIDaemonProcess eilive  python- 
            home=/var/www/html/eiapp/eiapp/venv/lib/python3.6/site-packages
            WSGIScriptAlias /eiapp /var/www/html/eiapp/eiapp.wsgi
            <Directory /var/www/html/eiapp/eiapp/>
                    Order allow,deny
                    Allow from all
            </Directory>
            Alias /static /var/www/html/eiapp/eiapp/static
            <Directory /var/www/html/eiapp/eiapp/static/>
                    Order allow,deny
                    Allow from all
            </Directory>
            ErrorLog ${APACHE_LOG_DIR}/error.log
            LogLevel warn
            CustomLog ${APACHE_LOG_DIR}/access.log combined

  </VirtualHost>

0 个答案:

没有答案