1

I am trying to upload an image using flask uploads, but it is not uploading (python 3.6), I have also given www-data user and group to static folder and given 777 permission also , but it's still not working:

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

ERROR : 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 file ::

<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>
simanacci
  • 2,197
  • 3
  • 26
  • 35
prashant
  • 21
  • 4

0 Answers0