﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
17955	Uploading a file without using django forms	alexandre@…	nobody	"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!

"	Bug	closed	HTTP handling	1.3	Normal	invalid	HttpRequest, MultiPartParser		Accepted	0	0	0	0	0	0
