1

我正在使用烧瓶来处理图像上传,每当我上传 jpg、jpeg 或 png 时,我制作的程序都能够处理上传。但是,无论何时上传 .jfif 图像,程序都会返回错误flask_uploads.UploadNotAllowed。提前感谢您的帮助!

程序有问题的代码是:

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

完整追溯:

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
4

1 回答 1

0

您可能正在使用标准IMAGES集:

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

此设置不允许.jfif文件。

但是,这样的集合实际上只是一个 Python 集合,因此您可以创建和使用自己的集合,或者只是更新现有的集合。

IMAGES.update(".jfif")

于 2021-01-26T06:15:03.470 回答