Ticket #5386: file-field-content-type.diff

File file-field-content-type.diff, 951 bytes (added by Petr Marhoun <petr.marhoun@…>, 17 years ago)
  • django/newforms/fields.py

    === modified file 'django/newforms/fields.py'
     
    350350
    351351class UploadedFile(StrAndUnicode):
    352352    "A wrapper for files uploaded in a FileField"
    353     def __init__(self, filename, content):
     353    def __init__(self, filename, content, content_type):
    354354        self.filename = filename
    355355        self.content = content
     356        self.content_type = content_type
    356357
    357358    def __unicode__(self):
    358359        """
     
    371372        if not self.required and data in EMPTY_VALUES:
    372373            return None
    373374        try:
    374             f = UploadedFile(data['filename'], data['content'])
     375            f = UploadedFile(data['filename'], data['content'], data['content-type'])
    375376        except TypeError:
    376377            raise ValidationError(ugettext(u"No file was submitted. Check the encoding type on the form."))
    377378        except KeyError:
Back to Top