#17955: Uploading a file without using django forms -------------------------------------+------------------------------------- Reporter: alexandre@… | Owner: nobody Type: | Status: new Cleanup/optimization | Version: 1.3 Component: HTTP handling | Keywords: HttpRequest, Severity: Normal | MultiPartParser Triage Stage: Unreviewed | Has patch: 0 Easy pickings: 0 | UI/UX: 0 -------------------------------------+------------------------------------- Hi,
i was trying to upload a file to my django backend without using django forms, but i was not able to it : my file was constantly getting dropped by the multiparser! my multipart/formdata post request has two standard string post values : Content-Disposition: form-data; name="foo" \r\n\r\n and one file : Content-Disposition: form-data; filename="bar"\r\n Content-Type: image/png\r\n\r\n I made it work simply by changing the multipartparser.py file this way : Current : {{{ 92 def parse(self): ... 141 try: 142 disposition = meta_data['content- disposition'][1] 143 field_name = disposition['name'].strip() 144 except (KeyError, IndexError, AttributeError): 145 continue }}} New : {{{ def parse(self): ... field_name = '' try: disposition = meta_data['content-disposition'][1] if disposition.has_key('name'): field_name = disposition['name'].strip() else: field_name = disposition['filename'].strip() except (KeyError, IndexError, AttributeError): continue }}} I think the change is pretty straightforward, and would be really nice! -- Ticket URL: <https://code.djangoproject.com/ticket/17955> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To post to this group, send email to django-updates@googlegroups.com. To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-updates?hl=en.