1

我正在尝试使用烧瓶上传上传图像,但它没有上传(python 3.6),我还将 www-data 用户和组授予静态文件夹并授予 777 权限,但它仍然无法正常工作:

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>
4

0 回答 0