1

I am using flask to handle image uploads and whenever I upload a jpg, jpeg, or png the program I made is able to handle the upload. However, whenever uploading a .jfif image the program returns the error flask_uploads.UploadNotAllowed. Thanks for any help in advance!

The code the program is having an issue with is:

file_name = photos.save(request.files['photo'])

full traceback:

Traceback (most recent call last):
  File 

    "C:\Users\user\AppData\Local\Programs\Python\Python36\lib\site-packages\flask\app.py", line 2464, in __call__
        return self.wsgi_app(environ, start_response)
      File "C:\Users\user\AppData\Local\Programs\Python\Python36\lib\site-packages\flask\app.py", line 2450, in wsgi_app
        response = self.handle_exception(e)
      File "C:\Users\user\AppData\Local\Programs\Python\Python36\lib\site-packages\flask\app.py", line 1867, in handle_exception
        reraise(exc_type, exc_value, tb)
      File "C:\Users\user\AppData\Local\Programs\Python\Python36\lib\site-packages\flask\_compat.py", line 39, in reraise
        raise value
      File "C:\Users\user\AppData\Local\Programs\Python\Python36\lib\site-packages\flask\app.py", line 2447, in wsgi_app
        response = self.full_dispatch_request()
      File "C:\Users\user\AppData\Local\Programs\Python\Python36\lib\site-packages\flask\app.py", line 1952, in full_dispatch_request
        rv = self.handle_user_exception(e)
      File "C:\Users\user\AppData\Local\Programs\Python\Python36\lib\site-packages\flask\app.py", line 1821, in handle_user_exception
        reraise(exc_type, exc_value, tb)
      File "C:\Users\user\AppData\Local\Programs\Python\Python36\lib\site-packages\flask\_compat.py", line 39, in reraise
        raise value
      File "C:\Users\user\AppData\Local\Programs\Python\Python36\lib\site-packages\flask\app.py", line 1950, in full_dispatch_request
        rv = self.dispatch_request()
      File "C:\Users\user\AppData\Local\Programs\Python\Python36\lib\site-packages\flask\app.py", line 1936, in dispatch_request
        return self.view_functions[rule.endpoint](**req.view_args)
      File "c:\Users\user\Desktop\OCR - Copy\OCRWebsite\app.py", line 421, in upload
        file_name = photos.save(request.files['photo'])
      File "C:\Users\user\AppData\Local\Programs\Python\Python36\lib\site-packages\flask_uploads.py", line 416, in save
        raise UploadNotAllowed()
    flask_uploads.UploadNotAllowed
Jürgen Gmach
  • 5,366
  • 3
  • 20
  • 37
Python 123
  • 59
  • 1
  • 13
  • Does this answer your question? [Flask-Uploads always throwing 'UploadNotAllowed' error even with no constraints](https://stackoverflow.com/questions/31884903/flask-uploads-always-throwing-uploadnotallowed-error-even-with-no-constraints) – Iron Fist Jan 26 '21 at 02:08
  • No, that is a different reason – Jürgen Gmach Jan 26 '21 at 06:10

1 Answers1

0

You are probably using the standard IMAGES set:

https://github.com/jugmac00/flask-reuploaded/blob/f05077b085393dbc607c01b8daff1b3a8b2dbf0b/src/flask_uploads/extensions.py#L29

This set does not allow .jfif files.

However, such a set is really only a Python set, so you can create and use your own, or just update the existing one.

IMAGES.update(".jfif")

Jürgen Gmach
  • 5,366
  • 3
  • 20
  • 37
  • Hello, where would I use this code in my program? – Python 123 Jan 27 '21 at 00:04
  • As said above, you can update the `IMAGES` set just after you imported it, where you use also create your app and do the `photos = UploadSet("photos", IMAGES)` or instead of importing `IMAGES` you just create one, also before creating the `UploadSet`. – Jürgen Gmach Jan 27 '21 at 07:30