S
S
s1auka2015-01-26 14:57:07
Django
s1auka, 2015-01-26 14:57:07

Why is MultiValueDict empty {} after image loading?

I want to simulate the work of the browser. When I send an image from the browser to request.FILES I get this:

<MultiValueDict: {u'file': [<InMemoryUploadedFile: 1.jpg (image/jpeg)>]}>

If I send a POST request from the back end:
import httplib
    conn = httplib.HTTPConnection(HOST, PORT)
    headers = {"Content-type": "application/x-www-form-urlencoded",      "Accept": 'text/plain', 
    "Cookie": cookies, 'X_REQUESTED_WITH': 'XMLHttpRequest'}
    conn.request("POST", "/upload/%s" % storyId, open("pictures/1.jpg"), headers)
    response = conn.getresponse()

I get:
<MultiValueDict: {}>
What's wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey K, 2015-01-26
@mututunus

Content-type: multipart/form-data

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question