knlklabacka
knlklabacka

Reputation: 109

Flask FileNotFoundError: [Errno 2] No such file or directory: xxxx.jpg

I'm hoping you can help. I'm running a Flask website that I want users to load a URL to an image. For example example.com/uploads/image_name.jpg. I'm using the code listed below and I can't seem to figure this out. I keep getting the following:

FileNotFoundError: [Errno 2] No such file or directory: '/home/xxx/uploads/image_name.jpg'

    app.config['UPLOAD_FOLDER'] = '/home/xxx/Flask/uploads'
    
    @app.route('/uploads/<path:filename>')
    def uploads(filename):
        return send_file(app.config['UPLOAD_FOLDER'] + filename)
        #return send_from_directory(app.config['UPLOAD_FOLDER'], filename)

Upvotes: 0

Views: 972

Answers (1)

knlklabacka
knlklabacka

Reputation: 109

Sorry for the trouble I figured this out. I had a typo in the file name.

Upvotes: 0

Related Questions